Possible Duplicate:
Handling session timeout in ajax calls
I want to handle timeout error on ajax call where i have set session timeout to 1 minute like..
<authentication mode="Forms">
forms loginUrl="~/User/Login" timeout="1" />
/authentication>
and my call for every ajax request is like..
$.ajax({
url: '../Document/getData?did=' + docid2,
beforeSend: function () {
$("#DialogData").empty().html('<p class="Loadimg"></p>');
},
success: function (result) {
$("#DialogData").load('../Document/getData?did=' + docid2);
},
error: function (req, status, xhr) {
alert(xhr);
//for Timeout Error
if (status == "timeout") {
$("#DialogData").empty().html('<p>Plese Try Again</p><');
}
if (status == "error") {
//for Page Not Found Invalid URL
if (xhr == "Not Found") {
}
//for server error which is from controller
if (xhr == "Internal Server Error") {
}
} //if error
} //error
}); //Ajax
but on timeout i get internal server error...i want to handle timeout error differently than other error so what should i do..where i can differntiate this error.because now if session timeout it gives internal server error or if any other server error occure it gives same internal server error as xhr value..when session timeout it display that login page which is redirect from controller is in div where i am calling $("#DIVID").load(..)..
..i want to redirect as soon as session timout on load to entire login page...
how can i do...thanks in advanced..
my code from controller side for redirection is..
/// <summary> /// The Logout method Removes the Authentication Ticket from the browser /// </summary> /// <returns>Redirection to the Login Page of Site</returns> [Authorize] public ActionResult Logout() { FormsAuthentication.SignOut(); return RedirectToAction("Login", "User"); } public bool IsUserLoggedIn() { if (!String.IsNullOrEmpty(System.Web.HttpContext.Current.User.Identity.Name)) { return true; } return false; } public int GetLoggedInUserId() { if (!IsUserLoggedIn()) return -1; return Convert.ToInt32(System.Web.HttpContext.Current.User.Identity.Name); }