WebApi允许跨域

            services.AddCors(options =>
            {
                options.AddPolicy("abc", builder =>
                {
                    //App:CorsOrigins in appsettings.json can contain more than one address with splitted by comma.
                    builder
                      .SetIsOriginAllowed(_ => true)
                        .AllowAnyHeader()
                        .AllowAnyMethod()
                        .AllowCredentials();

                });
            });
     app.UseCors("abc"); //这句代码要放在所有 app.xxx() 前面

 

posted @ 2020-08-19 14:06  IWing  阅读(187)  评论(0编辑  收藏  举报