Lets enable CORS in Web API 2
Use Nuget,
Step (1).
Go to: TOOLS > Library Package Manager > Package Manager Console, and type in:
Install-Package Microsoft.AspNet.WebApi.Cors
Step (2).
Add these line in WebApiConfig.cs file which is inside App_Start folder
public static void Register(HttpConfiguration config)
{
//enable cores
var enableCorsAttribute = new EnableCorsAttribute("*","Origin, Content-Type, Accept","GET, PUT, POST, DELETE, OPTIONS");
config.EnableCors(enableCorsAttribute);
}
And ya thats all its done.
Author Profile
![PREM KUMAR](https://pkworlz.com/wp-content/uploads/2021/12/WhatsApp-Image-2021-06-24-at-8.47.49-PM-min-150x150.jpeg)
- Hey Its..! Tech Lover , Ionic, Angular, Typescript, Dotnet Core, Node, Like Opencv, AI, ML, Robotics, Iot, Love Music, Cooking, Girls, Innovation