Need Httpclient example

rfresh

Active member
Joined
Aug 23, 2012
Messages
26
Programming Experience
1-3
I'm new to C# programming and am looking for a simple way to use Httpclient to fetch a text file from my website.

I've found some examples but they produce errors because I don't know how to declare them in the Usings section. Experienced C# coders know how to do this but new coders don't, thus I can't run the examples. Then I see many different ways to use Httpclient.

Can someone show me a simple way to use Httpclient and what using declarations I need?

I found this code which looks pretty simple:

C#:
var client = new HttpClient(); var response = client.Get("http://example.org");

I want to display the response in a label on my form so I'm going to use this code:

C#:
lbl_Results.Text = response;

Will that work on the response object? I tried some example code before and this line wouldn't work because response wasn't a string.

Thanks for any help...
 
Back
Top Bottom