我需要在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. 如何在PHP中延长会员会话时间
- 3. 如何在页面加载时延长会话超时时间?
- 4. Asp.net MVC3长时间轮询会话
- 5. 会话超时绝不会在asp.net mvc
- 6. asp.net mvc会话超时
- 7. MVC ASP.net会话是空的
- 8. 会话在ASP.NET中为空
- 9. 如何延长有多种表格的会话时间
- 10. MediaWIki会话空闲时间
- 11. 在asp.net中防止会话超时mvc
- 12. 在ASP.NET MVC中处理会话超时
- 13. ASP.NET会话过期时间
- 14. ASP.Net中的会话超时问题MVC
- 15. ASP.NET MVC中的会话超时警告
- 16. 长时间运行请求期间的ASP.NET会话超时
- 17. 在ASP.NET MVC中,为什么会话时TempData不会持久?
- 18. mvc会话超时
- 19. ASP.NET MVC会话
- 20. 回调延长/刷新会话吗? ASP.NET
- 21. 长时间php会话的缺点
- 22. 尽管在web.config中设置会话时间,会话超时
- 23. ASP.NET中的会话超时
- 24. 会话超时ASP.Net
- 25. ASP.NET - 会话超时
- 26. 如何在asp.net中处理会话mvc
- 27. 如何增加Asp .Net MVC 5中的会话超时时间?
- 28. 长时间打开数据库会话
- 29. ravendb长时间运行会话
- 30. 为基于ajax的文件上传延长会话超时
见http://stackoverflow.com/questions/21990619/how-to-increase-session-timeout-in-asp-net? –
可以从javascipt/jquery扩展吗? –
你的意思是,如果你的会话超时20分钟和15分钟过去,并在该会话超时重新设置20分钟右? –