Answer the question
In order to leave comments, you need to log in
How to send a request to a site through a proxy address?
I'm trying to send a request to a site through a proxy like this
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://whoer.net/ru");
var proxy = new WebProxy("190.151.107.50", 5678);
request.Proxy = proxy;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string ping;
using (StreamReader stream = new StreamReader(
response.GetResponseStream(), System.Text.Encoding.UTF8))
{
ping = stream.ReadToEnd();
}
Console.WriteLine(ping);
}
Answer the question
In order to leave comments, you need to log in
Perhaps the proxy you're using doesn't support http s ?
Try another proxy. It is advisable to check it first.
Also, before creating the request, add:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
this enables https support in HttpWebRequest
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question