简体   繁体   English

C#中的会话超时

[英]Session Timeout in C#

I am working in a web application project using asp.net ,my problem is I want to increase my Session time out to 1 hour ,For that I have used in web.config file: 我在使用asp.net的Web应用程序项目中工作,我的问题是我想将会话时间增加到1小时,为此我在web.config文件中使用了:

 <sessionState timeout="60" cookieless="false" mode="InProc"/>

but it is not working. 但它不起作用。

The Particular Page automatically redirects to login page after a few minutes.Why it is happening so? 几分钟后,“特殊页面”会自动重定向到登录页面。为什么会这样?

If you want to set the timeout to 1 hour then use the following 如果要将超时设置为1小时,请使用以下命令

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

It seems that client cookie is being expired and the IIS redirects user to login page to authenticate again. 客户端cookie似乎已过期,并且IIS将用户重定向到登录页面以再次进行身份验证。 It is not relevant with sessionState timeout. 它与sessionState超时无关。 Try to set timeout of FormsAuthentication ; 尝试设置FormsAuthentication超时;

<authentication mode="Forms">
  <forms loginUrl="~/Account/LogIn" timeout="60" />
</authentication>

In web config file, change sessionstate timeout propety 在Web配置文件中,更改会话状态超时属性

<system.web>  
    <sessionState mode="InProc" cookieless="false" timeout="60"/>
</system.web>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM