Session and AJAX timeout in ASP.NET

I have a button that executes a script using AJAX. Usually, when the session is still active, the script will return some data that will be placed inside the parent page. If the session has expired, AJAX will return a login screen that fits inside the parent page, which looks very strange.

How can I determine the session timeout and postback on the parent page?

+3
source share
3 answers

Since you are unlikely to call a full page, and your login page is likely to be complete, you can simply do the following.

if (xmlhttp.responseText.indexOf("DOCTYPE") != -1) {
    window.location.href = window.location.href;
}
+2
source

, , Nothing/null. , , , . - , , , .

0

What does it mean "if the session has expired, AJAX will return the login screen"? You control the return value, so instead of returning the login screen, return some kind of error code or you better throw an exception that you can catch as an error on the client.

0
source

Source: https://habr.com/ru/post/1755854/


All Articles