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
- Hey Its..! Tech Lover , Ionic, Angular, Typescript, Dotnet Core, Node, Like Opencv, AI, ML, Robotics, Iot, Love Music, Cooking, Girls, Innovation