码迷,mamicode.com
首页 > Web开发 > 详细

.NetCore跨域

时间:2020-06-20 14:06:17      阅读:66      评论:0      收藏:0      [点我收藏+]

标签:str   color   red   ati   span   sep   tin   cors   uil   

 

 

  "App":  {
  "CorsOrigins": "http://manage.l.cn,http://www..cn,https://www.lu.cn,,http://u.cn,https://portal.edu.cn"
  },

 

 

  services.AddCors(options =>
            {
                options.AddPolicy("localhost", builder =>
                {
                    //App:CorsOrigins in appsettings.json can contain more than one address with splitted by comma.
                    builder
                        .WithOrigins(
                            // App:CorsOrigins in appsettings.json can contain more than one address separated by comma.
                            _appConfiguration["App:CorsOrigins"]
                                .Split(",", StringSplitOptions.RemoveEmptyEntries)
                                .Select(o => o.RemovePostFix("/"))
                                .ToArray()
                        )
                        .SetIsOriginAllowedToAllowWildcardSubdomains()
                        .AllowAnyHeader()
                        .AllowAnyMethod()
                        .AllowCredentials();
                });
            });

 

.NetCore跨域

标签:str   color   red   ati   span   sep   tin   cors   uil   

原文地址:https://www.cnblogs.com/wangyinlon/p/13168171.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!