1 August 2021

How to enable CORS in ASP.NET Core

 open startup.cs page .net core project

In ConfigureServices() method:

public void ConfigureServices(IServiceCollection services)

{

 --------                 

  services.AddCors();

 --------

}

In Configure() method:

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

  {

  --------

   app.UseCors(builder =>

          builder.AllowAnyOrigin()

          .AllowAnyHeader()

          .AllowAnyMethod()

        );

  --------

  }


No comments:

Post a Comment