TL; DR: I\'m new to this language and have no idea what I\'m doing
here is my class so far:
using System;
using System.Collections.Generic;
using Sys
How I solved it.
In my case i had at the beginning .Net 4.0 and "Assemblies" -> "Extensions" option "System.Net.Http" with version 2.0.0.0. After my actions "Assemblies" -> "Framework" options "System.Net.Http" and "System.Net.Http" had the same 4.0.0.0 version.
HttpClient lives in the System.Net.Http namespace.
You'll need to add:
using System.Net.Http;
And make sure you are referencing System.Net.Http.dll
in .NET 4.5.
The code posted doesn't appear to do anything with webClient
. Is there something wrong with the code that is actually compiling using HttpWebRequest
?
Update
To open the Add Reference dialog right-click on your project in Solution Explorer and select Add Reference.... It should look something like:
Assuming that your using Visual Studio 10, you can download an install that includes System.Net.Http, for Visual Studio 10 here: download MVC4 for VS10
Once you've installed it, right click on the References folder in the VS Project and then select Add Reference. Then, select the Browse tab. Navigate to the assemblies install path for the MVC4 install (usually in Program Files(x86)/Microsoft ASP.NET/ASP.NET MVC4/assemblies) and select the assembly named 'System.Net.Http.dll'. Now you can add your 'using System.Net.Http' at the top of your code and begin creating HttpClient connections.
I had this issue after upgrading to .NET Framework 4.7.2. I found out that Nuget package for System.Net.Http is no longer recommended. Here are workarounds:
In Visual Studio you can use nuget to load the package
Microsoft.AspNet.WebApi.WebHost
To solve the problem :
Net framework 4.5
to finish loadingSystem.Net.Http
and click ok.Problem solved.