I'm looking for a way to prevent the SessionState from refreshing when I make an AJAX post to a controller.
This controller returns a JSON true/false object if the SessionState has expired.
Public Class JsonController
Inherits BaseController
Function SessionCheck()
If Session("Contact") Is Nothing Then
Return Json(JsonResponseFactory.ErrorResponse("Invalid contact"))
End If
Return Json(JsonResponseFactory.SuccessResponse())
End Function
End Class
Javascript:
function session_check_function() {
if (!session_check_complete)
return;
session_check_complete = false;
jQuery.post(
base_url + 'json/SessionCheck',
{},
function (data) {
if (!data.Success) {
jQuery('#session-modal').modal('show');
} else {
jQuery('#session-modal').modal('hide');
}
session_check_complete = true;
}
).fail(function () {
jQuery('#session-modal').modal('show');
session_check_complete = true;
});
}
var session_check_complete = true;
var session_check = setInterval(function () { session_check_function(); }, 2500);
The problem is the session keeps refreshing everytime I do a POST to the controller, I don't want it to refresh.