在Startup.cs文件中添加以下两处代码
public void ConfigureServices(IServiceCollection services) { services.AddCors(); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseCors(builder => builder .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); }