Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc Internet Explorer在注销时未重定向到未经授权的页面_Asp.net Mvc_Angularjs_Authentication_Wif - Fatal编程技术网

Asp.net mvc Internet Explorer在注销时未重定向到未经授权的页面

Asp.net mvc Internet Explorer在注销时未重定向到未经授权的页面,asp.net-mvc,angularjs,authentication,wif,Asp.net Mvc,Angularjs,Authentication,Wif,我们有一个带有MVC后端的Angular JS应用程序,它使用WIF使用Azure ASC对用户进行身份验证。MVC控制器具有[Authorize]属性,因此当未经身份验证的用户试图访问需要身份验证的页面时,他们会收到401错误 因此,过程如下: 尝试访问Home/Index 接收401错误 Angular httpInterceptor在401上拾取并使用$location.path(“/unauthorized”)重定向到未经授权的(登录)页面 用户单击登录按钮并重定向到Azure ACS进

我们有一个带有MVC后端的Angular JS应用程序,它使用WIF使用Azure ASC对用户进行身份验证。MVC控制器具有
[Authorize]
属性,因此当未经身份验证的用户试图访问需要身份验证的页面时,他们会收到401错误

因此,过程如下:

  • 尝试访问
    Home/Index
  • 接收401错误
  • Angular httpInterceptor在401上拾取并使用$location.path(“/unauthorized”)重定向到未经授权的(登录)页面
  • 用户单击登录按钮并重定向到Azure ACS进行身份验证
  • 成功身份验证后,用户将被引导回具有身份验证令牌的站点,并可以访问受保护的资源 角度http拦截器:

          // On response failture
            responseError: function (rejection)
            {
                // console.log(rejection); // Contains the data about the error.
                if (rejection.status == 401)
                {
                    $location.path("/unauthorized");
                    return $q.when(rejection);
                }
                // Return the promise rejection.
                return $q.reject(rejection);
            }
    
    当我第一次加载页面时,所有浏览器的行为都符合预期

    问题发生在我注销时。除了IE以外的所有浏览器都会出现以下情况

  • 通过重定向到注销URL执行单次注销
  • 注销后,将重定向回默认页面,但由于我现在没有身份验证令牌,因此收到401
  • 我被重定向到未经授权(登录)页面
  • 然而,当使用IE时,401不会发生在上面的第2步中。因此,会发生注销,但会加载默认页面。没有任何angular脚本加载,因为我在以下razor语句中加载了所有angular控制器、服务和指令:

    @if (User.Identity.IsAuthenticated)
    {
        //load angular files here
    }
    
    当我看到fiddler的情况时,我可以看到401计划并没有发生在IE上

    但它在其他浏览器中也有:


    为什么401不能像其他浏览器一样出现在IE上?

    我能够通过将一些角度文件移到下面语句之外来解决这个问题

    @if (User.Identity.IsAuthenticated)
    {
        //load angular files here
    }
    
    不知道为什么IE在重新定向之前需要这些,而不是其他浏览器