in ,

C# – Enable CORS in Web API 2

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");

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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

What do you think?

400 Points
Upvote Downvote
Ionic 3 In 3 Easy Steps

Ionic 3 In 3 Easy Steps | Ionic 3 quick installation guide | Ionic 3 for beginners

405 method not allowed - pkworlz

405 Method Not Allowed error with PUT or DELETE Request on ASP.Net application