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.
Asked
Active
Viewed 1,386 times
0

Racil Hilan
- 24,690
- 13
- 50
- 55

padh
- 95
- 1
- 3
- 14
-
See http://stackoverflow.com/questions/21990619/how-to-increase-session-timeout-in-asp-net ? – James P Sep 20 '16 at 09:44
-
is it ok if extend from javascipt/jquery? – Sandip - Frontend Developer Sep 20 '16 at 10:05
-
you mean, if your session time out 20 Min and 15 Min elapse and after that session time out again reset to 20 Min right? – Sandip - Frontend Developer Sep 20 '16 at 10:06
-
yes @SandipPatel. ok for javascript – padh Sep 20 '16 at 10:07
2 Answers
1
Try This In Your Web.config file,
change the timeout given ,
now the timeout is set to 60 minutes
<configuration>
...
<system.web>
<sessionState mode="InProc" timeout="60" />
</system.web>
...
</configuration>

Vinu Davis
- 56
- 4
0
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.
}

Sandip - Frontend Developer
- 14,397
- 4
- 35
- 61