.net 4.5 升级后 System.Web.Http 丢失

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27819109/
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:52:11  来源:igfitidea点击:

System.Web.Http missing after .net 4.5 upgrade

.netasp.net-mvcasp.net-web-api.net-4.5

提问by Kev

I've just upgraded my solution to .net 4.5 using Target Framework Migrator, and then the package manager console command:

我刚刚使用Target Framework Migrator将我的解决方案升级到 .net 4.5 ,然后是包管理器控制台命令:

Update-Package -Reinstall -IgnoreDependencies

Update-Package -Reinstall -IgnoreDependencies

In one of my projects I am using:

在我使用的一个项目中:

using System.Web.Http.Controllers;
using System.Web.Http.Filters;

The code uses HttpActionContextand ReflectedHttpActionDescriptor. I notice that System.Web.Httphas been removed from my references, and is no longer available in the Add New Reference window. What's going on?

该代码使用HttpActionContextReflectedHttpActionDescriptor。我注意到System.Web.Http已从我的参考文献中删除,并且在“添加新参考文献”窗口中不再可用。这是怎么回事?

回答by Steen T?ttrup

Have you looked in the Extensions part of the "Add new reference", instead of Framework ?

您是否查看了“添加新引用”的扩展部分,而不是框架?

If it's not there, it's in the Microsoft.AspNet.WebApi.Core package on NuGet.

如果它不存在,则它位于 NuGet 上的 Microsoft.AspNet.WebApi.Core 包中。

回答by Ezra Steinmetz

As for VS2017 - as said in the asp.net forumsMicrosoft has moved the namespace to a Nuget package called Web Api Core. In order to install it you need to typeInstall-Package Microsoft.AspNet.WebApi.Corein the Nuget Package Manager Console.

至于 VS2017 - 正如在asp.net 论坛中所说,微软已将命名空间移至名为Web Api Core的 Nuget 包。为了安装它,您需要输入Install-Package Microsoft.AspNet.WebApi.CoreNuget 包管理器控制台。

回答by Vinay Patel

Just run the following nuget command:

只需运行以下 nuget 命令:

Install-Package Microsoft.AspNet.WebApi.Core

回答by Igor Podolskiy

I do this

我这样做

Update-Package -Reinstall 

and it helped to my project be well done

它帮助我的项目做得很好