CORS in .NET Core

前端 未结 10 1091
失恋的感觉
失恋的感觉 2020-12-04 23:30

I am trying to enable CORS in .NET Core in this way:

    public IConfigurationRoot Configuration { get; }

    public void ConfigureServices(IServiceCollecti         


        
10条回答
  •  臣服心动
    2020-12-05 00:23

    You just need to add this in ConfigureService Method of StartUp Class

    services.AddCors ();
    

    and this in Configure Method of Startup Class and it will work fine then

    app.UseCors (builder => builder
                     .AllowAnyOrigin ()
                     .AllowAnyHeader ()
                     .AllowAnyMethod ());
    

    There is nothing more to add to enable CORS in .Net Core

提交回复
热议问题