首先,确认IIS服务器上是否已经安装了Windows身份验证功能。
检查ASP.NET Web API中是否已经开启了Windows身份验证功能。对于.NET Core应用程序,可以在Startup.cs文件中的ConfigureServices方法中配置,如下所示:
services.AddAuthentication(IISDefaults.AuthenticationScheme);
对于.NET Framework应用程序,可以在Web.config文件中添加以下代码:
import { HttpClient } from '@angular/common/http';
constructor(private http: HttpClient) {}
const options = { withCredentials: true };
this.http.get('https://api.example.com/data', options);
通过以上步骤,您应该可以解决ASP.NET Web API和Angular 7在IIS服务器上出现身份验证错误的问题。