ASP.NET 的默认会话超时值是多少?
根据MSDN,会话空闲的分钟数达到20分钟时会话将被取消。
来自MSDN:
可选的TimeSpan属性。
指定会话在空闲多少分钟后被放弃。对于in-process和state-server模式,timeout属性不能设置为大于525,601分钟(1年)的值。 会话超时配置只适用于ASP.NET页面。修改会话超时值不会影响ASP页面的会话超时。同样,修改ASP页面的会话超时不会影响ASP.NET页面的会话超时。 默认值为20分钟。
这取决于配置或程序化更改。因此,检查当前值最可靠的方式是通过代码在运行时进行。
请参阅HttpSessionState.Timeout属性;默认值为20分钟。
您可以通过HttpContext在ASP.NET中访问此属性:
this.HttpContext.Session.Timeout // ASP.NET MVC controller
Page.Session.Timeout // ASP.NET Web Forms code-behind
HttpContext.Current.Session.Timeout // Elsewhere
默认值为20分钟。 http://msdn.microsoft.com/en-us/library/h6bb9cz9(v=vs.80).aspx
<sessionState
mode="[Off|InProc|StateServer|SQLServer|Custom]"
timeout="number of minutes"
cookieName="session identifier cookie name"
cookieless=
"[true|false|AutoDetect|UseCookies|UseUri|UseDeviceProfile]"
regenerateExpiredSessionId="[True|False]"
sqlConnectionString="sql connection string"
sqlCommandTimeout="number of seconds"
allowCustomSqlDatabase="[True|False]"
useHostingIdentity="[True|False]"
stateConnectionString="tcpip=server:port"
stateNetworkTimeout="number of seconds"
customProvider="custom provider name">
<providers>...</providers>
</sessionState>
会话的默认过期时间为20分钟。
您可以更新sessionstate并在超时下配置分钟数。
<sessionState
timeout="30">
</sessionState>
int check = this.HttpContext.Session.Timeout;
来获取值 20,但是我能否使用键设置会话超时?并且如何检查特定键的会话超时,例如:Session["mykey"]
? - Shaiju TTimeout
属性值以分钟为单位。 - kmdsax