问题
In my web.config file, the session state configuration is as follows-
<sessionState mode="InProc" timeout="540" />
In IIS 7, session time out value alse 540. But still, session expires very quickly (within 5-15 minutes).
It is an asp.net mvc 4 application. Except login.cshtml, all other .cshtml views are loaded via ajax calls as a partial view. i.e. main home page loads only once and all other subsequent pages are loaded within a div on main home page.
How to get rid of this problem?
回答1:
if you are want session timeout for website than remove
<authentication mode="Forms">
<forms timeout="50"/>
tag from web.config file.
and add
<system.web>
<sessionState mode="InProc" timeout="60">
</sessionState>
in web.config file
and
void Session_Start(object sender, EventArgs e)
{
Session.Timeout = 60;
}
in Global.asax
回答2:
see
http://www.codeproject.com/Articles/113287/Why-Session-Timeout-is-not-working-for-your-websit
in resume: you have to configured it at IIS Application level
来源:https://stackoverflow.com/questions/21410630/session-expires-too-quickly-in-asp-net-mvc4-application