加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – ASP .NET MVC 3.会话过期太快了

发布时间:2020-12-16 09:23:44 所属栏目:asp.Net 来源:网络整理
导读:我有一个页面(View),它在某些时间间隔内发送 AJAX查询.用户可以很长时间使用此页面.但会议在大约40-60分钟后到期.所以AJAX请求不会返回有用的信息. 我的Web.config system.web sessionState timeout="259200" cookieName="SunTest.SessionId" regenerateExpi
我有一个页面(View),它在某些时间间隔内发送 AJAX查询.用户可以很长时间使用此页面.但会议在大约40-60分钟后到期.所以AJAX请求不会返回有用的信息.

我的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

<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>

它使这些饼干:

所以,有3个cookie:

> SunTest.SessionId. 301字节.到期 – 会话.
> ASPXFORMSAUTH. 301字节.到期 – 会话.
> .ASPROLES. 565字节.到期 – 星期二,2012年7月10日04:14:48 GMT

但是几分钟后(大约30-40),它会删除.ASPROLES cookie.用户已退出.因此,AJAX查询不起作用.

这个配置有什么问题?

解决方法

您的所有用户是否同时失去会话状态?如果是这样,您的应用程序池可以回收. There are several reasons why this can happen.

我建议您考虑设置用户会话管理,以便能够在应用程序和会话重新启动后继续运行. Here are some options.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读