How to send an HTTPS GET Request in C#

Clair Vengs picture Clair Vengs · Jun 3, 2009 · Viewed 151.1k times · Source

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

How to send an HTTPS GET Request in C#?

Answer

Kevin Newman picture Kevin Newman · Jun 3, 2009

Add ?var1=data1&var2=data2 to the end of url to submit 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();