GlobalConfiguration.Configure() not present after Web API 2 and .NET 4.5.1 migration

后端 未结 11 1948
后悔当初
后悔当初 2020-12-02 08:24

I recently started following this guide to migrate my project to .NET 4.5.1 and Web Api 2.

The very first thing MS developer Rick Anderson asks you to do is change:<

相关标签:
11条回答
  • 2020-12-02 08:46

    It needs the system.web.http.webhost which is part of this package. I fixed this by installing the following package:

    PM> Install-Package Microsoft.AspNet.WebApi.WebHost 
    

    or search for it in nuget https://www.nuget.org/packages/Microsoft.AspNet.WebApi.WebHost/5.1.0

    0 讨论(0)
  • 2020-12-02 08:50

    None of these solutions worked for me. I had a tangle of Nuget packages that couldn't update because of circular dependencies on each other.

    I would up having to fix this the old-fashioned way. I created a new MVC/web api project and manually copied System.Web.Http and System.Web.Http.WebHost from the new project into the Nuget folders of the exisitng solution. From there I updated the references by, OMG, "browsing" and fixed the problem.

    0 讨论(0)
  • 2020-12-02 08:52

    None of these ideas helped my project using MVC 5.2.2.

    • System.web.Http 5.2.2 was already installed
    • Deleting the Packages folder and completely re-downloading all NuGet libraries did nothing
    • Web.config already had a dependentAssembly entry for System.Web.Http

    Forcing a reinstall corrected the problem. From the NuGet package manager console:

    update-Package -reinstall Microsoft.AspNet.WebApi.WebHost

    0 讨论(0)
  • 2020-12-02 08:53

    "Install-Package Microsoft.AspNet.WebApi.Core" worked just fine.

    0 讨论(0)
  • 2020-12-02 08:58

    My problem was that the nuget package manager did not do a real update but the files contained references to older versions, so i first removed all the installed mvc related packages (including razor and web api) then installed them over again and updating the version of the razor in views/web.config to version 3.0.0.

    0 讨论(0)
提交回复
热议问题