2

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" };
}

}
1
  • You are confusing System.Web.Http and System.Net.Http, at least in the question. It should be System.Web.Http. You need to add a reference to the System.Web.Http Assembly (in Visual Studio: Solution Explorer -> your project -> References -> Add Reference) Commented Mar 14, 2018 at 11:56

1 Answer 1

1

System.Web.Http is different to System.Net.Http

  • Add the reference to System.Web.Http and then
  • And then using System.Web.Http;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.