简体   繁体   English

AspNet.Cors和AspNet.WebApi.Cors有什么区别?

[英]What is the difference between AspNet.Cors and AspNet.WebApi.Cors?

In my application I have the following two nuget packages installed: 在我的应用程序中,我安装了以下两个nuget包:

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

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?

  1. Microsoft.AspNet.WebApi.Cors : use it to enable the CORS request ONLY for the Web APIs . Microsoft.AspNet.WebApi.Cors :使用它仅为Web API启用CORS请求。

  2. Microsoft.AspNet.Cors : I think you can use this when you want to enable CORS for your MVC controllers . Microsoft.AspNet.Cors :我想您可以在为MVC控制器启用CORS时使用它。

  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. Microsoft.Owin.Cors :使用它为来自您站点的所有跨源请求启用CORS,因此,如果您使用Web APISignalR ,并且您想为两者启用CORS - 请使用Microsoft.Owin.Cors库。

Hope that helps. 希望有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在CORS环境中jQuery AJAX调用之间的ASPNET会话 - ASPNET Session between jQuery AJAX calls in a CORS enviroment IIS 和 Aspnet 容器有什么区别? - What is the difference between IIS &Aspnet Containers? Microsoft.AspNet.WebApi.Cors:请求的资源不支持 http 方法“OPTIONS” - Microsoft.AspNet.WebApi.Cors: The requested resource does not support http method 'OPTIONS' Aspnet MVC中的相对路径和绝对路径有什么区别? - What is the difference between Relative and Absolute paths in Aspnet MVC? 适用于Aspnet和Aspnet-Angular的Yoeman生成器之间的区别 - Difference between Yoeman generators for aspnet and aspnet-angular ABP(AspNet 样板)API 的间歇性 CORS 策略问题 - Intermittent CORS policy issue with ABP (AspNet Boilerplate) API AspnetRoles和aspnet_Roles之间的区别 - Difference between AspnetRoles and aspnet_Roles 网页与aspnet表,有什么区别? - webpages vs aspnet tables, what is the difference? Microsoft.Aspnet.identity.Core与Microsoft.AspNetCore.Identity之间有什么区别 - What is the difference between Microsoft.Aspnet.identity.Core vs Microsoft.AspNetCore.Identity 什么是aspnet_Users和aspnet_Membership? 我应该使用哪一个? 有什么不同? - What is aspnet_Users and aspnet_Membership? Which one should I use? What is the difference?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM