How to send HTTPS GET request in C #

Related: how-do-i-use-webrequest-to-access-an-ssl-encrypted-site-using-https

How to send HTTPS GET request in C #?

+46
Jun 03 '09 at 9:38
source share
3 answers

Add ?var1=data1&var2=data2 to the end of the URL to send values ​​to the page via GET:

 using System.Net; using System.IO; string url = "https://www.example.com/scriptname.php?var1=hello"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream resStream = response.GetResponseStream(); 
+72
Jun 03 '09 at 9:45
source
β€” -

I prefer using WebClient, it seems to handle SSL transparently:

http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx

Some troubleshooting help here

https://clipperhouse.com/webclient-fiddler-and-ssl/

+3
Jun 03 '09 at 19:42
source

A simple get request using the HttpClient class

 using System.Net.Http; class Program { static void Main(string[] args) { HttpClient httpClient = new HttpClient(); var result = httpClient.GetAsync("https://www.google.com").Result; } } 
0
Aug 12 '18 at 9:44
source



All Articles