The type or namespace IHttpActionResult not found

前端 未结 11 2007
小鲜肉
小鲜肉 2021-01-31 14:04

This is the first time I am creating a Web API application in ASP.NET MVC4. I opened a new Web API project and added a new controller named \'Product\'. The function given below

相关标签:
11条回答
  • 2021-01-31 14:29

    Using NuGet to install the Web API2 Core lib. dll. You may have to update Nuget before install ing Web API2 because some components in API2 not compatible with old Nuget package. I had done this way and problem was resolved.

    0 讨论(0)
  • 2021-01-31 14:30

    Check with this link to get the namespace for IHttpActionResult and all.

    This package contains everything you need to host ASP.NET Web API on IIS. ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework.

    To install Microsoft ASP.NET Web API 2, run the following command in the Package Manager Console Or Manage NuGet Packages

    PM> Install-Package Microsoft.AspNet.WebApi -Version 5.0.0

    0 讨论(0)
  • 2021-01-31 14:31

    I had similar problem & re installation will solve this issue. Just go to Tools > NuGet Package Manager > Package Manager Console in Visual Studio 2013 and write down the following :-

    PM> update-Package Microsoft.AspNet.WebApi –reinstall
    

    Then, Clean the solution and Build/Rebuild the solution.

    Note: In my case, the process explicitly checked out Web.config and packages.config file and also removed the System.Web.Http dll file.

    0 讨论(0)
  • 2021-01-31 14:31

    FYI I was getting the same issue when using .NET Core 3.1.

    The solution was to use IActionResult instead of IHttpActionResult.

    0 讨论(0)
  • 2021-01-31 14:33

    This solution worked for me:
    Tools – > Library Package Manager -> Package Manager Console, then type:
    Install-Package Microsoft.AspNet.WebApi -Version 5.0.0
    update-Package Microsoft.AspNet.WebApi –reinstall
    Reference: http://blog.bitlinkit.com/type-namespace-ihttpactionresult-not-found/

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