【问题标题】:ASP.NET authentication sessionASP.NET 身份验证会话
【发布时间】:2012-05-16 00:37:49
【问题描述】:

我在一个 ASP.NET 表单身份验证下有许多站点。他们有混合框架(一些有 2.0,一些 4.0,但一切都很好) 一切正常,但有时,在随机时间(例如两分钟)后,客户端上的会话结束,他必须再次输入密码.为什么?我错过了什么?

这是我的 web.config 的一部分:

<authentication mode="Forms" ><forms loginUrl="../web/start_page/start_page.aspx"
    name=".ASPXFORMSAUTH" 
    protection="All"  
    path="/" 
    timeout="60" /></authentication>  
<machineKey
  validationKey="blablabla"
  validation="SHA1" />
<sessionState mode="InProc" stateNetworkTimeout="3600" />

事件查看器显示:

Event code: 4005 
Event message: Forms authentication failed for the request. Reason: The ticket supplied    has expired. 
Event time: 21.09.2010 8:23:26 
Event time (UTC): 21.09.2010 4:23:26 
Event ID: e3a00bef332a4dec9cd1aa078a3d5aa4 
Event sequence: 277 
Event occurrence: 1 
Event detail code: 50202 

【问题讨论】:

  • 您是否查看了 firebug 中的 cookie 以了解“过期”设置为什么?
  • 可能是网站上的服务器时钟不同步?检查它们的日期,以及客户端机器上的日期。

标签: c# asp.net authentication


【解决方案1】:

因为发生了会话超时事件,所以你需要像这样增加会话时间

<configuration>
  <sessionstate 
      mode="inproc"
      cookieless="false" 
      timeout="20" 
      sqlconnectionstring="data source=127.0.0.1;user id=<user id>;password=<password>"
      server="127.0.0.1" 
      port="42424" 
  />
</configuration>

超时。此选项控制会话被视为有效的时间长度。会话超时是一个滑动值;在每个请求上,超时时间设置为当前时间加上超时值

【讨论】:

  • 所以我有 timeout=60,为什么不适合?
  • @eba -- 在 msdn 上查看超时属性以增加超时时间
  • sessionstate 配置与表单身份验证 cookie 超时无关。
  • @RPM1984 - 根据我的说法,由于会话超时,他仅从站点退出
  • 我不明白你的评论,对不起。我试图说明的是会话是服务器端的(添加购物车,会话 [“购物车”] = 购物车;)。该项目的到期由您上述答案完成。但是forms auth cookie是客户端的,到期是通过forms timeout=60完成的,他有。形成身份验证 cookie != 会话。
猜你喜欢
  • 2020-01-19
  • 2011-10-09
  • 1970-01-01
  • 2010-10-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-16
  • 2015-05-15
相关资源
最近更新 更多