C#

This article provides an example of using a proxy to make an HTTP request with the C# programming language.

C-Sharp



In this example, we use the Residential proxy below:

resi.ipv6.plainproxies.com:8080:customer:product--resi6--pass--nicepass

This proxy is split into four parts separated by colons. We first save the proxy as a string variable, then split it into four parts at each colon and then add it, with authentication, to our proxy dictionary.


using System;  
using System.Net;  
using System.IO;  
  
class Program  
{  
    static void Main(string[] args)  
    {  
        string proxyAddress = "resi.ipv6.plainproxies.com:8080";  
        string proxyUsername = "customer";  
        string proxyPassword = "product--resi6--pass--nicepass";  
  
        WebProxy proxy = new WebProxy(proxyAddress, true);  
        proxy.Credentials = new NetworkCredential(proxyUsername, proxyPassword);  
  
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://google.com");  
        request.Proxy = proxy;  
  
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();  
        StreamReader reader = new StreamReader(response.GetResponseStream());  
        string responseText = reader.ReadToEnd();  
  
        Console.WriteLine(responseText);  
    }  
}

Updated on: 20/02/2025

Was this article helpful?

Share your feedback

Cancel

Thank you!