11

I am new to C#, I need to send HTTP GET request and read answer. I am familiar with Java and easy can do it URLConnection class but I don't know in c#. Can anybody help ?

Jelena
  • 147
  • 1
  • 4

1 Answers1

18

The simplest way is to use WebClient:

WebClient client = new WebClient();
string text = client.DownloadString(url);

(That's the synchronous form; it also supports asynchronous requests.)

For more control you might want to use HttpWebRequest.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194