System.Web.Http missing after .net 4.5 upgrade

2019-04-17 21:53发布

问题:

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

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 HttpActionContext and ReflectedHttpActionDescriptor. I notice that System.Web.Http has been removed from my references, and is no longer available in the Add New Reference window. What's going on?

回答1:

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.



回答2:

As for VS2017 - as said in the asp.net forums Microsoft 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.Core in the Nuget Package Manager Console.