I have an application that uses about 20 http generic handler for ajax call .
I used IReadOnlySessionState to access the session in my handlers. Everything is working fine.
But when the session ends, my handler returns some html, as it redirects to the default page, and the default html of the page is sent back to the response.
To solve this problem.
I checked the session variable in the handler, and if it is null, I wrote
context.Response.Write("logout")
And I check jQuery ajax weather, is it a logout or something else.
$.ajax({ url: "myhandler.ashx", contentType: "application/json; charset=utf-8", success: function (data) { checklogout(data); $("#loading").hide(); }, error: function () { $("#loading").hide(); }, async: false });
If this is logout, I used the location to redirect to the login page.
I use form-authentication to authenticate the user.
Is there a better approach for checking and redirecting to the login page using jquery-ajax call.
source share