This post will discuss how to make an HTTP GET request in C#.

1. Using WebClient.DownloadString() method

The System.Net.WebClient class provides several utility methods for sending data and receiving data from a URI resource. You can use the WebClient.DownloadString() method to download a resource as a string. The following example illustrates the usage of this method.

Download  Run Code

 
Note that the WebClient.DownloadString() method blocks the calling thread while downloading the resource. To download a resource asynchronously without waiting for the server’s response, consider using the WebClient.DownloadStringAsync() method.

2. Using HttpWebRequest Class

Alternatively, you can use the System.Net.HttpWebRequest class, which is an HTTP-specific implementation of the WebRequest class. For more information on this class, see the official documentation.

Download  Run Code

3. Using HttpClient Class

The HttpWebRequest class is not recommended anymore. It is preferable to use the System.Net.Http.HttpClient class instead.

Download  Run Code

That’s all about making an HTTP GET request in C#.