.net core 3.1 设置可跨域
2021-01-23 15:15
阅读:692
标签: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的调用之间执行。 配置不正确将导致中间件停止正常运行。
.net core 3.1 设置可跨域
标签:option eth color div ring put uil 必须 conf
原文地址:https://www.cnblogs.com/lbonet/p/13277515.html
上一篇:ASP.Net Cookie
下一篇:php的各种 I/O流 以及用法
文章来自:搜素材网的编程语言模块,转载请注明文章出处。
文章标题:.net core 3.1 设置可跨域
文章链接:http://soscw.com/index.php/essay/45943.html
文章标题:.net core 3.1 设置可跨域
文章链接:http://soscw.com/index.php/essay/45943.html
评论
亲,登录后才可以留言!