我正在编写一个Angular 4应用程序,需要从Asp.Net WebApi获取一些数据 . 我们正在使用WebAPI的表单身份验证,当我开始使用表单身份验证时,我遇到了这个问题:
“因此不允许对预检请求做出响应't pass access control check: No ' Access-Control-Allow-Origin ' header is present on the requested resource. Origin ' http://localhost:4200” .
响应标头:
{
Server=Microsoft-IIS
Access-Control-Allow-Origin=http://localhost:4200,
Access-Control-Allow-Credentials=true,<br>
...
Methods=GET
}
我的web.config:
<authentication mode="Forms">
<forms loginUrl="SomeLoginWebSite"
timeout="90"
name="Name"
protection="All"
path="/"
enableCrossAppRedirects="true">
</forms>
</authentication>
<authorization>
<deny users="?"/>
<allow users="*"></allow>
</authorization>