Global "ajax call" notification with asp.net mvc/jquery

Posted by Joel Martinez on Stack Overflow See other posts from Stack Overflow or by Joel Martinez
Published on 2010-05-12T16:40:24Z Indexed on 2010/05/12 16:44 UTC
Read the original article Hit count: 499

Filed under:
|
|
|

I need to be notified any time a largeish asp.net mvc web application makes an ajax call to the server. We're using both jquery, and the built-in Ajax.* methods to do the remote calls, and I would like a global way of knowing when we make a call without having to manually inject some sort of "IsMakingCall" method to every request.

The root problem we're trying to solve is session timeout. If the user leaves a page up and goes to lunch (for example), they get errors when they get back because the ajax call is returning the login page instead of the expected json or partial html result.

My idea was to have a js timer which would be reset any time we make an ajax call. That way, if the timer runs out (ie. their session has now timed out) I can just auto-log them out. This is how sites like bank of america and mint.com work.

Thanks!

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about AJAX