我需要在MVC中延长会话超时以维护用户会话。试图让global.asax中的Session_End
延长会话,但它没有奏效。如何在ASP.Net MVC中的会话为空时延长会话时间?
0
A
回答
0
你必须呼叫控制器方法在特定的时间间隔根据您的要求重置会话超时通过这种方式您的应用程序集中在一定的时间间隔。
将您的jQuery代码布局
JQuery的:
var RefreshSessionInterval;
$(document).ready(function() {
clearInterval(RefreshSessionInterval);
RefreshSessionInterval = setInterval("RefreshSession()", 30000); // change your interval time as per requirement
});
function RefreshSession() {
$.ajax({
type: "POST",
url: '@Url.Action("RefreshSession", "YourControllerName")',
success: function (data) {
},
error: function() {
}
});
}
控制器:
Public void RefreshSession()
{
//your session reset from this line, as i know you don't have to write any code here.
}
+0
你可以请更新我是否工作或不? –
1
试一试在你的web.config文件,
更改超时现在给出, 超时设置为60分钟
<configuration>
...
<system.web>
<sessionState mode="InProc" timeout="60" />
</system.web>
...
</configuration>
相关问题
- 1. 会话时间延长
- 2. 如何在asp.net中延长会话超时时间
- 3. 如何在PHP中延长会员会话时间
- 4. 如何在页面加载时延长会话超时时间?
- 5. 延长CruiseControl.NET会话持续时间
- 6. 在ASP.NET MVC会话超时
- 7. 会话超时在Asp.Net中延伸
- 8. 如何延长会话超时持续时间?
- 9. Asp.net MVC3长时间轮询会话
- 10. 会话超时绝不会在asp.net mvc
- 11. asp.net mvc会话超时
- 12. ASP.NET MVC 4会话超时
- 13. 会话不会长时间粘住
- 14. 如何确定Asp.Net会话时长
- 15. 在asp.net中的会话超时mvc
- 16. MVC ASP.net会话是空的
- 17. 会话在ASP.NET中为空
- 18. 如何延长有多种表格的会话时间
- 19. 在asp.net中防止会话超时mvc
- 20. 在ASP.NET MVC中处理会话超时
- 21. MediaWIki会话空闲时间
- 22. ASP.NET会话过期时间
- 23. ASP.NET MVC中的会话超时警告
- 24. ASP.Net中的会话超时问题MVC
- 25. 在ASP.NET MVC中的会话
- 26. 在ASP.NET MVC中,为什么会话时TempData不会持久?
- 27. 长时间运行请求期间的ASP.NET会话超时
- 28. ASP.NET MVC会话
- 29. ASP.NET MVC会话为空。会话变量没有被设置
- 30. mvc会话超时
见http://stackoverflow.com/questions/21990619/how-to-increase-session-timeout-in-asp-net? –
可以从javascipt/jquery扩展吗? –
你的意思是,如果你的会话超时20分钟和15分钟过去,并在该会话超时重新设置20分钟右? –