简体   繁体   English

在MVC中几秒钟后,asp.net会话自动过期

[英]Asp.net session expiring automatically after few seconds in MVC

When user login, I'm storing user_id in Session variable and on second page I'm checking on page load if user_id exists then fine, otherwise redirect to sign in page but when I login and and redirected to next page after few seconds it will redirect on login page. 当用户登录时,我将user_id存储在Session变量中,在第二页上,我正在检查页面加载情况下是否存在user_id,然后很好,否则重定向到登录页面,但是当我登录并在几秒钟后重定向到下一页时,它将在登录页面上重定向。 I have tried all solutions but all in vain 我尝试了所有解决方案,但都没有用

Important Note: Another thing is that application working fine on development server and also on local IIS in LAN but on live server this issue is occurring. 重要说明:另一件事是该应用程序在开发服务器以及LAN上的本地IIS上都可以正常运行,但在实时服务器上会出现此问题。 Following web.config file code is 以下web.config文件代码是

 <system.web>
  <customErrors mode="Off" />
  <trust level="Full" />
  <authentication mode="Forms">
   <forms loginUrl="~/Security/Registration" timeout="30" 
         slidingExpiration="true"  />
  </authentication>
  <sessionState timeout="30"></sessionState>
  <compilation targetFramework="4.5" />
  <httpRuntime targetFramework="4.5" />
 </system.web>

为什么不用下面的行更新sessionState

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

You can set timeout in web.config 您可以在web.config中设置超时

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

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

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