Session expires too quickly in asp.net mvc4 application

久未见 提交于 2020-01-15 03:25:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!