I am using asp.net and I have $ .ajax calls in my web application for every server request.
I want to redirect the user to the login page at the end of the session.
In my web.config, I installed:
<authentication mode="Forms">
<forms name=".CovertixAuthenticated" defaultUrl="Default.aspx" loginUrl="LoginPage.aspx" slidingExpiration="true" cookieless="UseCookies" protection="All" timeout="1"/>
</authentication>
<sessionState mode="InProc" cookieless="UseCookies" timeout="1"/>
and I check .ajaxError:
$(document).ajaxError(function(xhr, props) {
if (props.status == 401) {
var ParentUrl = encodeURIComponent(window.parent.location.href);
document.location.href = getLoginPage() + "?ReturnUrl=" + ParentUrl;
}
});
The problem is that I get responseCode = 500 (internal server error)
What is the best way to check if a session has ended when ajax is called, or how can I redirect the user to the login page automatically when the session ends?
Inbal source
share