33

I'm trying to implement cors support in my Web API.

I have read a couple of blog posts on this topic, but I can't seem to find System.Web.Cors.dll or System.Web.Http.Cors.dll

Is there something I need to install?

Null Reference
  • 11,260
  • 40
  • 107
  • 184

4 Answers4

40

Create a .NET 4.5 MVC project, install nuget package "Microsoft ASP.NET Web API [version] Cross-Origin Support" (search for "cors" and it will be on 1st or 2nd place in list). That's it.

P.S. If you encounter errors try to install "Microsoft ASP.NET Web API [version]" package too (search for "WebApi").

Petr Abdulin
  • 33,883
  • 9
  • 62
  • 96
11

The System.Web.Cors assembly is now available on NuGet in the Microsoft.AspNet.Cors package. This is currently a prerelease package, so if you're using the Visual Studio package manager, you'll need to include prerelease packages.

Jaecen
  • 855
  • 1
  • 9
  • 17
2

The only way to use System.Web.Cors locally is to use the nightly builds as per this discussion. http://aspnetwebstack.codeplex.com/discussions/436442

Pieter Germishuys
  • 4,828
  • 1
  • 26
  • 34
2

According to this thread, you can get it using nightly builds of ASP.NET using nuget (see instructions here). But it sounds like it is only compatible with v5 of System.Web.Http so you'll potentially need to get that also. That is certainly not RTM so you'd have to be comfortable with that.

Simon C
  • 9,458
  • 3
  • 36
  • 55
  • So apart from this nightly builds, there's no other way to include cors support in an web api project? – Null Reference Apr 03 '13 at 04:38
  • AFAIK there is not. The initial check-in was only on March 13 so you're on the bleeding edge. You can of course download the source and build / play tinker yourself? – Simon C Apr 03 '13 at 04:43
  • 2
    Not tested out myself yet, but I did read about CORS support for web api in this post: http://www.stevefenton.co.uk/Content/Blog/Date/201211/Blog/Using-CORS-With-ASP-NET-Web-API/ – AardVark71 Apr 03 '13 at 07:22
  • @AardVark71 Interesting. Worth taking a look at. – Simon C Apr 03 '13 at 19:29
  • please try this in vs 2012 and try to download cors in nuget,there is no as such path or dll available for downloading. – Code Rider Jun 27 '13 at 14:24
  • @CodeRider How did you try? Did you add the new package source? Also, when you try to add a package, did you include pre-release? I can see the cors package when following the instructions. – Simon C Jun 27 '13 at 21:44