为什么ASP.NET MVC 3的会话过期速度这么快?有没有办法延长会话有效期?

2026-03-30 12:401阅读0评论SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计507个文字,预计阅读时间需要3分钟。

为什么ASP.NET MVC 3的会话过期速度这么快?有没有办法延长会话有效期?

我有页面(View),它会在某些时间间隔内发送AJAX查询。用户可以长时间使用此页面。但建议在大约40-60分钟后到期。因此,AJAX请求不会返回有用的信息。我的Web.config中system.web/sessionState的时间为:

我有一个页面(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查询不起作用.

这个配置有什么问题?

为什么ASP.NET MVC 3的会话过期速度这么快?有没有办法延长会话有效期?

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

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

本文共计507个文字,预计阅读时间需要3分钟。

为什么ASP.NET MVC 3的会话过期速度这么快?有没有办法延长会话有效期?

我有页面(View),它会在某些时间间隔内发送AJAX查询。用户可以长时间使用此页面。但建议在大约40-60分钟后到期。因此,AJAX请求不会返回有用的信息。我的Web.config中system.web/sessionState的时间为:

我有一个页面(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查询不起作用.

这个配置有什么问题?

为什么ASP.NET MVC 3的会话过期速度这么快?有没有办法延长会话有效期?

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

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