.net 引用 system.web.cors

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15778469/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 12:11:46  来源:igfitidea点击:

Referencing system.web.cors

.netweb-servicesrestasp.net-web-apicors

提问by Null Reference

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

我正在尝试在我的 Web API 中实现 cors 支持。

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

我已经阅读了一些关于这个主题的博客文章,但我似乎找不到 System.Web.Cors.dll 或 System.Web.Http.Cors.dll

Is there something I need to install?

有什么我需要安装的吗?

回答by Petr Abdulin

Create a .NET 4.5MVC 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.

创建一个.NET 4.5MVC 项目,安装 nuget 包“Microsoft ASP.NET Web API [版本] 跨域支持”(搜索“cors”,它将在列表中的第 1 或第 2 位)。就是这样。

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

PS 如果您遇到错误,请尝试安装“Microsoft ASP.NET Web API [版本]”包(搜索“WebApi”)。

回答by Jaecen

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

System.Web.Cors 程序集现在在Microsoft.AspNet.Cors包中的NuGet 上可用。这是当前的预发布包,因此如果您使用的是 Visual Studio 包管理器,则需要包含预发布包。

回答by Pieter Germishuys

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

根据本讨论,在本地使用 System.Web.Cors 的唯一方法是使用夜间构建。http://aspnetwebstack.codeplex.com/discussions/436442

回答by Simon C

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.

根据此线程,您可以使用 nuget 使用 ASP.NET 的夜间构建来获取它(请参阅此处的说明)。但听起来它只与 System.Web.Http 的 v5 兼容,因此您可能也需要获得它。这当然不是 RTM,因此您必须对此感到满意。