Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include System.Web.Http.Cors reference dll in .Net Web API

People also ask

How do I fix the CORS issue in Web API?

First, we need to enable CORS in WebAPI, then we call the service from other application AJAX request. In order to enable CORS, we need to install the JSONP package from NuGet (see Figure3). After adding Jsonp package, we need to add the following code-snippet in App_Start\WebApiConfig. cs file.

What is System Web CORS?

This class defines an attribute that can be applied to an action or a controller to enable CORS. By default, it allows all origins, methods and headers. Namespace: System.Web.Http.Cors.


Use Nuget, Microsoft use it for many great things as well.

Go to: TOOLS > Library Package Manager > Package Manager Console, and type in:

Install-Package Microsoft.AspNet.WebApi.Cors

Reference to the Nuget package here.

Here's another question on this topic


Answer from @Marcus is now outdated, System.Web.Http.Cors is no longer comes with Microsoft.AspNet.WebApi.Cors follow this link to install System.Web.Http.Cors Microsoft.AspNet.Cors