The type or namespace name "HTTP" doesn't exist in the namespace system.web error in .net 4.6.2

3.2k Views Asked by At

I am new to .net/C#. I am trying to build a project but getting a lot of missing reference error. When I am trying to install the packages like mentioned in example, I am getting error that it already exists in the project.

PM> Install-Package Microsoft.AspNet.WebApi.Core
Package 'Microsoft.AspNet.WebApi.Core.5.2.7' already exists in project 'XXXXXXystemApi'
Time Elapsed: 00:00:16.0349189

Also, as in below screenshot, I see that there are few references which have a little warning signs which might be pointing towards what is wrong with my setup.

The type or namespace name 'Http' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

enter image description here

I tried to Add references to the project but I am not seeing any entry for System.Web.Http under add reference dialog.

How do I fix all this ?

2

There are 2 best solutions below

0
On BEST ANSWER

Here is what finally solved my problem.

use NuGet and downgrade a version of library you are having issue with ; then re-install the right version. Accept Licenses (which is probably what was needed). Important: close and reopen visual studio.

Reference link : solution ref

1
On

Try running

dotnet restore

in the Package Manager Console

Also, unloading and reloading the project has worked for me before (Right-click on the project name in the Solution explorer to unload and reload)