The type or namespace IHttpActionResult not found

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

    Since you are using Asp.Net 4.0, IHttpActionResult is not available in Namespace System.Web.Http version 4.0 so you have to update your namespace to version 5.0.0.0. You can Check your namespace version by right click System.Web.Http namespace in references and go to properties. You can update this by Right Clicking on your Solution project->Manage NuGet Packages for Solution-> Search for Asp.Net WebAPI 2 ->Select Asp.Net WebAPI 2 and click Manage. Also you can check if it is available on update tab, if it is available in update tab you can update from there. Once you did that, confirm version by going to properties of System.Web.Http namespace in references.

    This works for me and hope will work for you too.

    Thanks

提交回复
热议问题