If a user is not authenticated for a long time, after Ajax-call, trying to find a solution for redirection on the login page Used to be.
I have used the method described here
private static zero redirectionToLogin {ActionExecutingContext filterContext} {string redirectOnSuccess = filterContext.HttpContext.Request.Url.AbsolutePath; String redirectUrl = string.Format ("ReturnUrl = {0}", Redirect On Six); String login url = formatting.login url + redirectional; FilterContext.HttpContext.Response.AddHeader ("REQUIRES_AUTH", "1"); FilterContext.HttpContext.Response.StatusCode = 401; FilterContext.HttpContext.Response.Redirect (loginUrl, true); }
Javascript is
$ (window) .ajaxComplete (function (request, request, settings) {warning (request.getResponseHeader ('REQUIRES_AUTH') ); Alert (request.status); if (request.getResponseHeader ('REQUIRES_AUTH') === 1) {window.location = App.basePath + "Login / Logon"; {});
If the user logged out was requested. GetResponseHeader ('REQUIRES_AUTH')) is always navigated
I think you are getting an empty value for "REQUIRES_AUTH" that your log In Page
~ / login / logon
authentication is not required which is correct, otherwise you will not be able to log in! Apart from this, your javascript has the wrong way of curly bracket. (Typing):
$ (window) .jaxComplete (function (event, request, settings) {warning (request.getResponseHeader ('REQUIRES_AUTH')); alerts (request.status) ; If (request.getResponseHeader ('REQUIRES_AUTH') === 1) {window.location = App.basePath + "Login / Logon";}});
I am also looking for a good solution for this problem, but still a little bit stuck. Have you solved this problem? If so, how did you manage it?
Comments
Post a Comment