- .net core 2.1 跨域问题
1.在Startup.cs的 ConfigureServices方法添加支持跨域中间件
services.AddCors();
2.在Configure方法添加代码
app.UseCors(builder => builder
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
3.如果Configure方法有UseMvc方法,一定要把UseCors方法写到UseMvc方法前面,要不然还是现实跨域。