- Go to: Tools > NuGet Package Manager > Package Manager Console
- Change the "Package source:" dropdown to be "nuget.org"
- Type in: Install-Package Microsoft.AspNet.Cors
- Put config.EnableCors(); in WebApiConfig which is a class found in the App_Start folder.
- Now slap [EnableCors(origins: "*", headers: "*", methods: "*")] on a Web API controller. It should work!
Addendum 12/20/2019: In modern times Install-Package Microsoft.AspNet.WebApi.Cors is probably the thing to use in step three above.
No comments:
Post a Comment