When i try to add ApiController to existing MVC project, it gives me the following error:
Error CS0234 The type or namespace name 'Http' does not exist in the namespace 'System.Web'
I updated and make sure that System.Net.Http referance is exist.
What is the couse?
The only code for this issue is the following and the error syntax i gave above.
public class ValuesController : System.Web.Http.ApiController
{
[HttpGet]
public IEnumerable<string> Values()
{
return new string[] { "value1", "value2" };
}
}
System.Web.HttpandSystem.Net.Http, at least in the question. It should beSystem.Web.Http. You need to add a reference to theSystem.Web.HttpAssembly (in Visual Studio: Solution Explorer -> your project -> References -> Add Reference)