标签:option eth color div ring put uil 必须 conf
1、Startup类里先定义一个全局变量:
readonly string MyAllowSpecificOrigins = "_myAllowSpecificOrigins";//名字随便起
2、ConfigureServices方法里写如下代码:
services.AddCors(options => { options.AddPolicy(MyAllowSpecificOrigins, builder => builder.AllowAnyOrigin() .WithMethods("GET", "POST", "HEAD", "PUT", "DELETE", "OPTIONS") ); });
3、Configure方法里添加中间件:
app.UseCors(MyAllowSpecificOrigins);
CORS 中间件必须配置为在对 UseRouting 和 UseEndpoints的调用之间执行。 配置不正确将导致中间件停止正常运行。
标签:option eth color div ring put uil 必须 conf
原文地址:https://www.cnblogs.com/lbonet/p/13277515.html