I need to extend the session timeout in MVC to maintain the user session. Tried to make session extend on Session_End
in global.asax but it didn't worked.
You have to call controller method at specific time interval as per your requirement to reset session timeout by this way your application got focused on some time interval.
Place your JQuery code in layout
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 () {
}
});
}
Controller:
Public void RefreshSession()
{
//your session reset from this line, as i know you don't have to write any code here.
}