我需要在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分鐘右? –