侧边栏壁纸
博主头像
小医仙博主等级

风一程雨一程,身向榆关那畔行。

  • 累计撰写 38 篇文章
  • 累计创建 16 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

在 .NET Core WebAPI 中,允许跨域请求

小医仙
2023-06-13 / 0 评论 / 0 点赞 / 145 阅读 / 41 字
public void ConfigureServices(IServiceCollection services)
{
    services.AddCors(options =>
    {
        options.AddPolicy("AllowAll", builder =>
        {
            builder.AllowAnyOrigin()
                   .AllowAnyMethod()
                   .AllowAnyHeader();
        });
    });
    
    // other service configurations
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    // other app configurations

    app.UseCors("AllowAll");
    
    // other app configurations
}

评论区