0

net 2.0,我希望管理会话变量超时 1 小时。

是否可以?如何?

我正在使用 Windows 身份验证。

4

1 回答 1

3

您可以在 web.config 中全局设置会话超时:

<configuration>
  <system.web>
    <sessionState 
      mode="InProc"
      cookieless="true"
      timeout="30" />
  </system.web>
</configuration>

您可以通过设置 Session.Timeout 以编程方式覆盖代码中的该设置(例如,仅用于管理员会话),例如:

// set the current session's timeout to 60 minutes
// if the current user is an admin
if (currentUserIsAdmin)
    Session.Timeout = 60; 

查看此 MSDN 页面了解详细信息。

于 2009-04-18T14:47:26.403 回答