I am working on a method to check for an invalid session variable in my asp.net project. Its a known fact that session variables tend to invalidate un-predictably in big projects.
Though I tried almost everything but with no success. Now I am working on a different way to handle it. Please refer jQuery form submit. I have a modal popup in the end of the form and then I have added the $("form").submit() event of jQuery to check for invalid session state and then if state is invalid, invoke login modal, which again using XHR sends the user login credentials to the server to recreate the session.(Please note that I am a little new to jQuery)
Here is my code:
$(document).ready(function () {
$("form").submit(formSubmit);
function formSubmit() {
$.get("CheckForSessionTimeOut.aspx", function (data) {
if (data == "0") // Session is null
{
getModal();//Method to invoke the popup
return false;
}
else if (data == "1") // Session is valid or not null
{
//submit the form
}
});
}
});
But the problem here is the form posts back without the modal with some javascript error. and in case if I use e.preventDefault();
to prevent from default postback in submit(); method the form does not posts back at all.