views:

53

answers:

2

I have a button that executes a script using AJAX. Normally when a session is still active the script will return some data that will be placed inside the parent page. If the session expired the AJAX will return the login screen which gets placed inside the parent page which looks really odd.

How would I be able to detect a session timeout and do a postback on the parent page?

A: 

When you make your call, first check to see if one of your session parameters is Nothing/null. If it is null, then your session has likely timed out. If you don't have any session variables that you explicitly set, you can set one when the user logs in.

MCain
A: 

What do you mean by 'if the session expired the AJAX will return the login screen'? You are in control of what is returned, so instead of returning the login screen return some sort of error code, or better throw an exception which you can catch as an error on the client.

James Gaunt
I am using forms authentication. When a page tries to load but the session has expired the page is redirected to the login screen by asp.net.
Arizona1911