When you’re using the asp.net membership and you have the [Authorize] tag on a controller / Action, sometimes when you get back from getting coffee / a walk whatever, you have been logged out of the site. When you click a button or link that invokes an Ajax call, the returned html is not what you requested but the login screen, which then get rendered somewhere on the page (if you use $(‘placeholder’).html(result)).
Is there anyway to detect this in jQuery ? As it is legit html you don’t get an error, but it’s not something you want to have happen ofcourse.
One thing that you could do is client-side session timeout detection. Set up a timer that will expire shortly before your actual session expires. Have the timer pop-up a dialog indicating that the session is about to expire and let the user have the opportunity to renew it (send back an AJAX request to refresh the session timer). Have another timer on the dialog that will expire before the time remaining on the actual session runs out. If this timer fires, then reset the href of the page to the logout url and log the user out. Obviously, the timers will need to be reset by user activity on the page — ajax requests, etc.