简体   繁体   中英

What is the difference between AspNet.Cors and AspNet.WebApi.Cors?

In my application I have the following two nuget packages installed:

  • Microsoft.AspNet.Cors - 5.2.2
  • Microsoft.AspNet.WebApi.Cors - 5.2.2

My application is a WebAPI back-end connected to an AngularJS front-end. The back-end and front-end are on different web servers. The application uses bearer authentication and logon is estabilished with a call to /token. I am using ASP.Net Identity 2.1

I have managed to get CORS working by following directions from here:

http://www.codeproject.com/Articles/742532/Using-Web-API-Individual-User-Account-plus-CORS-En

However I would like to learn more about the differences between the two Cors packages. Are they both required for my type of project and when would one use the AspNet.Cors and when would one use the WebApi.Cors?

  1. Microsoft.AspNet.WebApi.Cors : use it to enable the CORS request ONLY for the Web APIs .

  2. Microsoft.AspNet.Cors : I think you can use this when you want to enable CORS for your MVC controllers .

  3. Microsoft.Owin.Cors : use it to enable CORS for all cross-origins requests coming to your site, so if you use Web API and SignalR for example and you want to enable CORS for both - use Microsoft.Owin.Cors library.

Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM