标签:常用 config cors value tom configure 网上 ecif cal
修改web.config文件
<system.webServer> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Methods" value="GET,POST,PUT,DELETE,OPTIONS" /> <add name="Access-Control-Allow-Headers" value="content-type,signsvalue,timestamp,authorization" /> <add name="Access-Control-Allow-Credentials" value="true" /> <add name="Access-Control-Allow-Origin" value="http://81.70.41.226:8019" /> </customHeaders> </httpProtocol> </system.webServer>
从网上查看的常用方法,在ConfigureServices方法中添加代码,注意这样有可能不管用,需要一点点尝试,下面这三种都可以挨个试试,本人亲测。
services.AddCors(options => { options.AddPolicy("AllowSpecificOrigins", builder => { builder.WithOrigins("http://localhost:9527").AllowAnyHeader().AllowCredentials().AllowAnyMethod(); }); }); services.AddCors(options => { options.AddPolicy("AllowSpecificOrigins", builder => { builder.WithOrigins("http://localhost:9527").AllowAnyHeader().AllowCredentials(); }); }); services.AddCors(options => { options.AddPolicy("AllowSpecificOrigins", builder => { builder.WithOrigins("http://localhost:9527").AllowAnyHeader(); }); });
在Configure方法中添加代码
app.UseCors("AllowSpecificOrigins");
标签:常用 config cors value tom configure 网上 ecif cal
原文地址:https://www.cnblogs.com/dawenyang/p/14425266.html