ASP .NET MVC 3会话过期太快 [英] ASP .NET MVC 3. Session expired too quickly

查看:121
本文介绍了ASP .NET MVC 3会话过期太快的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面(视图),它发送AJAX查询一些间隔。用户可以通过此页面很长的时间工作。但是,会议约40-60分钟过期。因此,AJAX的请求不返回有用的信息。

I have a page (View), which sends AJAX queries in some intervals. User can work with this page very long time. But session expired in about 40-60 minutes. So AJAX-requests don't return usefull information.

我的web.config

My Web.config

<system.web>
  <sessionState
      timeout="259200"
      cookieName="SunTest.SessionId"
      regenerateExpiredSessionId="true"
      sqlCommandTimeout="200"
      stateNetworkTimeout="200">
  </sessionState>
<roleManager enabled="true" defaultProvider="SqlProvider" cacheRolesInCookie="true" cookieName=".ASPROLES" cookieTimeout="259200" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All">
  <providers>
    <add name="SqlProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="SqlServices" applicationName="/" />
  </providers>
</roleManager>
<authentication mode="Forms">
  <forms loginUrl="~" timeout="259200" protection="All" />
</authentication>   

我已经改变了我的web.config

I've changed my web.config

<appSettings>
    <add key="enableSimpleMembership" value="false" />
    <add key="autoFormsAuthentication" value="false" />
</appSettings>
<system.web>
  <sessionState 
      mode="SQLServer"
      allowCustomSqlDatabase="true"
      sqlConnectionString="Data Source=servername;Initial Catalog=dbname;User ID=username;Password=password"
      timeout="259200"
      cookieName="SunTest.SessionId"
      regenerateExpiredSessionId="true"
      sqlCommandTimeout="200"
      stateNetworkTimeout="200">
  </sessionState>
<roleManager createPersistentCookie="true" enabled="true" defaultProvider="SqlProvider" cacheRolesInCookie="true" cookieName=".ASPROLES" cookieTimeout="259200" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All">
  <providers>
    <add name="SqlProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="SqlServices" applicationName="/" />
  </providers>
</roleManager>
<authentication mode="Forms">
  <forms domain="help2b-2.hosting.parking.ru" name="ASPXFORMSAUTH" path="/" loginUrl="~" slidingExpiration="true" cookieless="UseCookies" timeout="259200" requireSSL="false" />
</authentication>

这使得这些cookie:

It makes these cookies:

因此​​,有3的Cookie:

So, there are 3 cookies:


  • SunTest.SessionId。 301字节。过期 - 会话

  • SunTest.SessionId. 301 byte. Expires - Session.

ASPXFORMSAUTH。 301字节。过期 - 会话

ASPXFORMSAUTH. 301 byte. Expires - Session.

.ASPROLES。 565字节。过期 - 星期二,2012年7月10日4点十四分48秒GMT

.ASPROLES. 565 byte. Expires - Tue, 10 Jul 2012 04:14:48 GMT

不过几分钟(东西约30-40)后,它将删除.ASPROLES的cookie。用户被注销。因此,AJAX查询不工作。

But after several minutes (something about 30-40), it deletes the .ASPROLES cookie. The user is signed out. So, AJAX queries don't work.

什么是错的这个配置?

推荐答案

都是你的用户在同一时间失去会话状态?如果是这样,你的应用程序池,可以循环利用。 <一href=\"http://blogs.msdn.com/b/johan/archive/2007/05/16/common-reasons-why-your-application-pool-may-unexpectedly-recycle.aspx\">There有几个原因,为什么会发生这种情况。

Are all your users losing session state at the same time? If so, your app pool could be recycling. There are several reasons why this can happen.

我会建议你考虑设置你的用户会话管理,使其能够生存的应用和会话重新启动。 这里有一些选择。

I would recommend you consider setting up your user session management so that it is able to survive application and session restarts. Here are some options.

这篇关于ASP .NET MVC 3会话过期太快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆