在ASP.NET MVC4应用程序中,会话过期太快 [英] Session expires too quickly in asp.net mvc4 application

查看:67
本文介绍了在ASP.NET MVC4应用程序中,会话过期太快的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的web.config文件中,会话状态配置如下-

In my web.config file, the session state configuration is as follows-

<sessionState mode="InProc" timeout="540" />

在IIS 7中,会话超时值也为540.但是,会话很快就会过期(在5至15分钟之内).

In IIS 7, session time out value alse 540. But still, session expires very quickly (within 5-15 minutes).

这是一个asp.net mvc 4应用程序.除了login.cshtml之外,所有其他.cshtml视图都通过ajax调用作为局部视图加载.也就是说,首页仅加载一次,所有其他后续页面均在div内加载到首页.

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.

如何摆脱这个问题?

推荐答案

如果您希望网站会话超时而不是删除

if you are want session timeout for website than remove

<authentication mode="Forms">
  <forms timeout="50"/>

来自web.config文件的标签.

tag from web.config file.

并添加

<system.web>
<sessionState mode="InProc" timeout="60">
</sessionState>

在web.config文件中

in web.config file

 void Session_Start(object sender, EventArgs e)
    {
        Session.Timeout = 60;
    }

在Global.asax中

in Global.asax

这篇关于在ASP.NET MVC4应用程序中,会话过期太快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆