Angular 7 Windows身份验证登录弹出窗口未显示

时间:2019-02-22 14:13:21

标签: angular windows-authentication angular7

我正在尝试在我的angular 7应用程序中使用Windows身份验证。我的问题是Windows集成身份验证的弹出窗口没有显示,并且向API提出请求时出现以下错误。

如果我使用restlet客户端直接向后端发出请求,或者只是使用Google Chrome浏览器直接发出请求,则Windows集成身份验证可以正常工作。

enter image description here

我在前端的代码如下:

win-auth.interceptor.ts

enter image description here

AppModule.ts

enter image description here

控制台输出: enter image description here

类似于以下问题,但该解决方案不适用于我:

Windows Authentication and Angular 4 application

我还尝试了以下教程:

https://spikesapps.wordpress.com/2017/08/04/how-to-implement-windows-authentication-in-an-angular-4-3-1-application-with-a-stand-alone-web-api/

编辑:

错误规范: enter image description here

后端Cors配置:

enter image description here

1 个答案:

答案 0 :(得分:0)

如果您注意到,则该错误与OPTIONS方法有关。这是在发出实际请求之前的飞行前请求。您需要确保在服务器端允许使用OPTIONS请求方法。

如果您使用的是WebAPI和IIS,则它具有用于OPTIONS请求的内置处理程序。确保您不会像下面那样在web.config中删除此处理程序。

<system.webServer>
    <handlers>
      <remove name="OPTIONSVerbHandler" />
    </handlers>
</system.webServer>

由于您设置了withCredentials: true选项,因此它与Access-Control-Allow-Credentials标头一起使用。 Angular的HttpClient发出OPTIONS请求,以检查允许的请求方法。而且在您的情况下,不允许使用OPTIONS方法。

相关问题