IHttpActionResult method cannot return NotFound()
asp.net-mvc, asp.net-web-api, c#
Solution
You need to inherit your controller from `ApiConroller` - that is where these methods are defined:
public class AccountController : ApiController
Problem
I am developing a web API for my website and have ran into a problem. At the moment, the API is supposed to return details from the specified user. This is my controller for accounts: ``` using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Http; using System.Net; using RoditRepoAPIV2.Models; namespace RoditRepoAPIV2.Controllers { public class AccountController : Controller { Account[] products = new Account[] { //accounts will be added... }; public IEnumerable<Account> GetAllAccounts() { return products; } public IHttpActionResult GetAccount(int id) { var account = products.FirstOrDefault((p) => p.Id == id); if (account == null) { return NotFound(); } return Ok(account); } } } ``` Although most of this code is copied from the tutorial here, Visual Studio complains that '`NotFound()`' and '`Ok(account)`' do not exist in the current context. I have updated all of the NuGet packages to version 5.1.2+ and I still get this error. I have done some research and found that it seems to work for other people... I would much appreciate it if anyone could respond with a working solution! Thank you.