In my application I have the following two nuget packages installed:
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?
Cross-origin resource sharing (CORS) is a browser security feature that restricts cross-origin HTTP requests that are initiated from scripts running in the browser. If your REST API's resources receive non-simple cross-origin HTTP requests, you need to enable CORS support.
Microsoft.AspNet.WebApi.Cors
: use it to enable the CORS request ONLY for the Web APIs.
Microsoft.AspNet.Cors
: I think you can use this when you want to enable CORS for your MVC controllers.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With