且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ASP.NET 中的会话超时

更新时间:2023-09-11 23:20:16

您是否使用表单身份验证?

Are you using Forms authentication?

表单身份验证使用自己的超时值(默认为 30 分钟).表单身份验证超时会将用户发送到会话仍处于活动状态的登录页面.这可能看起来像您的应用在会话超时时的行为,从而很容易将一个与另一个混淆.

Forms authentication uses it own value for timeout (30 min. by default). A forms authentication timeout will send the user to the login page with the session still active. This may look like the behavior your app gives when session times out making it easy to confuse one with the other.

<system.web>
    <authentication mode="Forms">
          <forms timeout="50"/>
    </authentication>

    <sessionState timeout="60"  />
</system.web>

将表单超时设置为小于会话超时可以为用户提供一个重新登录的窗口,而不会丢失任何会话数据.

Setting the forms timeout to something less than the session timeout can give the user a window in which to log back in without losing any session data.