The type or namespace IHttpActionResult not found

前端 未结 11 2023
小鲜肉
小鲜肉 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:16

    This issue seems to happen in 2 recent projects I have started using visual studio 2015. Project is an ASP.Net MVC 5 website with mvc and web api components. After running the updates and cleaning up unwanted nuget packages I copied some boilerplate code from another similar project and had the same issue with IHttpActionResult and RouteAttribute not found.

    The problem was due to the incorrect Version of the System.Web.Http.dll referenced in the project references. By default the system GAC version of the assembly is used.

    To fix this, simply remove this reference and add a reference to the same assembly in the Nuget package folder: [project folder]\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll

    You should check that your have updated to the required version of Microsoft.AspNet.WebApi.Core nuget package first.

提交回复
热议问题