响应未到达拦截器
Response not reaching interceptor
我已经在这上面花了几个小时无济于事,希望有人能对此有所启发。 (谢谢!)
我的拦截器:
appRoot.factory('myInterceptor', ["$window", "$q",'$location', function ($window, $q,$location) {
var sessionRecoverer = {
responseError: function(response) {
// Session has expired
if (response.status == 401) {
$location.path('/#/login');
}
return $q.reject(response);
}
};
return sessionRecoverer;
}]);
应用程序结束请求:
private void Application_EndRequest(object sender, EventArgs e)
{
if (!HttpContext.Current.User.Identity.IsAuthenticated)
{
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
var routeValues = HttpContext.Current.Request.RequestContext.RouteData.Values;
if (routeValues != null)
{
if (routeValues.ContainsKey("action"))
{
var actionName = routeValues["action"].ToString();
if (actionName.ToLower() != "login")
{
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
}
}
}
}
}
页面结果:
谢谢,我正在使用 Angular js (1)。这个问题似乎与我的 web.config 上的一些奇怪设置有关,身份验证表单超时转发到默认值 url 之类的事情。无法捕获奇怪的设置,所以我可以 post 在这里,但这有点解决了问题。
我已经在这上面花了几个小时无济于事,希望有人能对此有所启发。 (谢谢!)
我的拦截器:
appRoot.factory('myInterceptor', ["$window", "$q",'$location', function ($window, $q,$location) {
var sessionRecoverer = {
responseError: function(response) {
// Session has expired
if (response.status == 401) {
$location.path('/#/login');
}
return $q.reject(response);
}
};
return sessionRecoverer;
}]);
应用程序结束请求:
private void Application_EndRequest(object sender, EventArgs e)
{
if (!HttpContext.Current.User.Identity.IsAuthenticated)
{
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
var routeValues = HttpContext.Current.Request.RequestContext.RouteData.Values;
if (routeValues != null)
{
if (routeValues.ContainsKey("action"))
{
var actionName = routeValues["action"].ToString();
if (actionName.ToLower() != "login")
{
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
}
}
}
}
}
页面结果:
谢谢,我正在使用 Angular js (1)。这个问题似乎与我的 web.config 上的一些奇怪设置有关,身份验证表单超时转发到默认值 url 之类的事情。无法捕获奇怪的设置,所以我可以 post 在这里,但这有点解决了问题。