首页 asp.Net ASP.Net Forms身份验证在10分钟后注销用户

ASP.Net Forms身份验证在10分钟后注销用户

我遇到了一个非常糟糕的问题,无论我尝试什么,用户都会在10分钟后退出. 我正在使用运行在作为虚拟服务器的Server 2003 R2 Standard Edition上的IIS 6.0上运行的ASP.Net 2.0以及所有适用的更新和.Net 3.5 SP1. 客户端是Internet Explorer 7.0 以下是web.config

我遇到了一个非常糟糕的问题,无论我尝试什么,用户都会在10分钟后退出.

我正在使用运行在作为虚拟服务器的Server 2003 R2 Standard Edition上的IIS 6.0上运行的ASP.Net 2.0以及所有适用的更新和.Net 3.5 SP1.

客户端是Internet Explorer 7.0

以下是web.config设置:

<!-- Authentication Mode -->
<authentication mode="Forms">
  <forms name=".RecipeViewer" timeout="240" />
</authentication>

以下是用于设置授权cookie的代码:

Private Sub SetCookie(userName)
                ' Use security system to set the UserID within a client-side Cookie
                Dim ticket As New FormsAuthenticationTicket(1,userName,DateTime.Now,DateTime.Now.Add(Me.GetFormsAuthSettings.Forms.Timeout),True,String.Empty,FormsAuthentication.FormsCookiePath)
                Dim hash As String = FormsAuthentication.Encrypt(ticket)
                Dim cookie As New HttpCookie(FormsAuthentication.FormsCookieName,hash)

                cookie.HttpOnly = True

                If (ticket.IsPersistent) Then
                    cookie.Expires = ticket.Expiration
                End If

                Response.Cookies.Add(cookie)

                ' Redirect browser back to originating page
                Response.Redirect(Request.ApplicationPath)
End Sub

    Private Function GetFormsAuthSettings() As System.Web.Configuration.AuthenticationSection
        Return DirectCast(System.Configuration.ConfigurationManager.GetSection("system.web/authentication"),System.Web.Configuration.AuthenticationSection)
    End Function

我之前使用的是FormsAuthentication.SetAuthCookie,甚至尝试使用FormsAuthentication.RedirectFromLoginPage方法,但这些方法都有相同的结果,这就是为什么我最终做了内部完成的硬cookie实现(通过在Reflector中查看) FormsAuthentication类可以.

该问题无法在Visual Studio 2008 asp.net托管环境或IIS 7.0中重现.

编辑:启用Cookie,即使托管网站已添加为可信站点.

编辑:谷歌Chrome和Firefox没有这个问题.

编辑:已验证目标计算机上的Cookie设置为根据设置4小时后过期(超时= 240分钟).

编辑:众议院说,每个人都撒谎.用户实际上没有测试新的代码库,并且正在进行预先设想的概念,即该软件仍然被破坏.感谢所有在本主题中回复的人.

没有关闭它不再相关,但保持它可以帮助人们解决问题,因为在这个问题中有一些非常好的故障排除技术.

解决方法

它也可能(已经)机床密钥未设置,因此每次初始化应用程序时都会随机生成(这意味着加密的身份验证票证将使用新密钥加密).

我使用一个站点为我的应用程序生成一个新的机器密钥并将其粘贴到web.config中:

http://www.orcsweb.com/articles/aspnetmachinekey.aspx

<?xml version="1.0"?>

<configuration>

    <appSettings/>
    <connectionStrings/>
    <system.web>

        <machineKey validationKey='FED01BCB246D3477F5854D60388A701508AD1DF9099BD3CAC3CA4DAF55F7524B8DD3FA03133BBCA381BC1CD639730445968DFA633A97911187EF187456D692F4' decryptionKey='861E7DF7C2D04297EEFAD47FF3B95F54E87CF28D6C2753D8' validation='SHA1'/>

    </system.web>
</configuration>

本文来自网络,不代表青岛站长网立场。转载请注明出处: https://www.0532zz.com/html/kaifa/asp-net/20200731/7466.html
上一篇
下一篇

作者: dawei

【声明】:青岛站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

为您推荐

返回顶部