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");
原文地址:https://www.cnblogs.com/IWings/p/13529020.html