0

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.

Racil Hilan
  • 24,690
  • 13
  • 50
  • 55
padh
  • 95
  • 1
  • 3
  • 14

2 Answers2

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.
}