相关疑难解决方法(0)

.NET应用程序中的不稳定无效Viewstate问题

我似乎偶尔会在ASP.NET应用程序的事件查看器中获得"无效的视图状态" .

他们中的大多数(95%)似乎是引用ScriptResource.axd(该应用程序使用ASP.NET AJAX库).我无法删除Ajax库,因为到处都使用Ajax.

如何减少这些错误?我每天得到约100-200个错误,我不知道如何修复它们!它们来自不同的浏览器,不同的IP和地理位置.

我很难重现这个问题,因为它几乎没有发生在我身上,它只发生在我身上3-4次.

错误:

Process information: 
    Process ID: 4004 
    Process name: w3wp.exe 
    Account name: NT AUTHORITY\NETWORK SERVICE 

Exception information: 
    Exception type: HttpException 
    Exception message: Invalid viewstate. 

Request information: 
    Request URL: http://domainnamehere/ScriptResource.axd?d=W1R6x9VzZ2C9SKnIkOmX9VRLhSjJ3nOF1GSQvPwKS3html 
    Request path: /ScriptResource.axd 
    User host address: 124.177.170.75 
    User:  
    Is authenticated: False 
    Authentication Type:  
    Thread account name: NT AUTHORITY\NETWORK SERVICE 

Thread information: 
    Thread ID: 1 
    Thread account name: NT AUTHORITY\NETWORK SERVICE 
    Is impersonating: False 
    Stack trace:    at System.Web.UI.Page.DecryptStringWithIV(String s, …
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net viewstate

61
推荐指数
2
解决办法
3万
查看次数

使用ASP .Net Membership保持用户登录持久性

我有一个使用sql成员资格提供程序构建在ASP.NET 3.5和SQL Server 2005中的网站,并且可能是表单身份验证.

由于我网站上的安全需求非常低,我想进行一次身份验证,然后无限期地保持登录(不给用户选择).

发生的事情是用户登录,保持登录会话,然后下次他们到达时,他们会被注销.

如何保持登录?

这是技术细节,我已经尝试了许多持续时间的变化.

 Try
            If Membership.ValidateUser(UserName.Text, Password.Text) Then
                Security.UserManager.AuthenticateUser(UserName.Text)

                If FormsAuthentication.GetRedirectUrl(UserName.Text, False) = "/default.aspx" Then
                    Try
                        'Custom Logic'
                    Catch Ex As Exception
                        'Custom Error handling'
                    End Try
                Else
                    FormsAuthentication.RedirectFromLoginPage(UserName.Text, True)
                End If
            End If
        Catch ex As Exception
            RaiseEvent ExceptionThrown(New ApplicationException("An error occurred trying to log the user in after account creation.", ex))
        End Try

Public Shared Sub AuthenticateUser(ByVal Username As String)
    Dim Expiration As DateTime = DateTime.Now.AddMonths(3)

    Dim authTicket As FormsAuthenticationTicket = New FormsAuthenticationTicket(Username, …
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-membership asp.net-3.5 sqlmembershipprovider

18
推荐指数
2
解决办法
2万
查看次数

随机无效的Viewstate错误

我知道关于这个主题有很多问题,我已经全部阅读过了.

我正在使用IIS8,.Net 4.5.

用户随机获取无效的viewstate错误,我无法弄清楚.一旦发生这种情况,他们可以返回网站的唯一方法是清除浏览器缓存.

在我的web.config中,我有:

<system.web>
<machineKey validationKey='....key here'   decryptionKey='....decrypt key is valid here'   validation='SHA1'/>
    <!--<hostingEnvironment shadowCopyBinAssemblies="false" />-->
    <authentication mode="None" />
    <compilation targetFramework="4.5.1" />
    <httpRuntime targetFramework="4.5.1" />
...
</system.web>
Run Code Online (Sandbox Code Playgroud)

我正在运行虚拟专用服务器,而我还没有找到大于9​​kb的viewstate.

我的应用程序池设置为每天凌晨3:00重启,每天一次.

我的页面使用更新面板,也许用户点击"返回"?但我看到它只是访问页面而没有点击回来.

我注意到的一件事是我有3个不同的站点使用相同的应用程序池标识,但应用程序池是分开的.machine.xml中没有机器密钥,但只在我的web.config中.

c# asp.net webforms .net-4.5

11
推荐指数
1
解决办法
657
查看次数