[英]What is the difference between AspNet.Cors and AspNet.WebApi.Cors?
In my application I have the following two nuget packages installed: 在我的应用程序中,我安装了以下两个nuget包:
My application is a WebAPI back-end connected to an AngularJS front-end. 我的应用程序是一个连接到AngularJS前端的WebAPI后端。 The back-end and front-end are on different web servers. 后端和前端位于不同的Web服务器上。 The application uses bearer authentication and logon is estabilished with a call to /token. 该应用程序使用承载身份验证,并通过调用/ token建立登录。 I am using ASP.Net Identity 2.1 我正在使用ASP.Net Identity 2.1
I have managed to get CORS working by following directions from here: 我已按照以下说明设法让CORS工作:
http://www.codeproject.com/Articles/742532/Using-Web-API-Individual-User-Account-plus-CORS-En 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. 但是我想了解更多关于两个Cors包之间差异的信息。 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? 它们都是我的项目类型所必需的,何时使用AspNet.Cors,何时使用WebApi.Cors?
Microsoft.AspNet.WebApi.Cors
: use it to enable the CORS request ONLY for the Web APIs . Microsoft.AspNet.WebApi.Cors
:使用它仅为Web API启用CORS请求。
Microsoft.AspNet.Cors
: I think you can use this when you want to enable CORS for your MVC controllers . Microsoft.AspNet.Cors
:我想您可以在为MVC控制器启用CORS时使用它。
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. Microsoft.Owin.Cors
:使用它为来自您站点的所有跨源请求启用CORS,因此,如果您使用Web API和SignalR ,并且您想为两者启用CORS - 请使用Microsoft.Owin.Cors
库。
Hope that helps. 希望有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.