Using your FoxyProxy Account with .NET C#

  1. Home
  2. Programmatically accessing your Proxy
  3. Using your FoxyProxy Account with .NET C#

Here’s a code snippet that uses your FoxyProxy account with .NET C#.

This example connects to through a proxy server with your proxy username and password. Be sure to replace username, password, and port (typically 3128 or 13129) in this example with your account information.

The C# client connects to the proxy server using HTTP and instructs the proxy server to connect to the final destination (

Although this example uses the HTTP proxy server on port 3128, other ports are available (usually 13129) with your account. HTTPS proxy server access is also available on the port 4443, which encrypts traffic between your client and FoxyProxy proxy servers. Your account also comes with SOCKS5 proxy server access, typically on port 21. You can find this information by logging into your account at the Control Panel.

using System;
using System.IO;
using System.Net;
using System.Text;

namespace test
class MainClass
public static void Main(string[] args)
Console.WriteLine("Hello World!");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("");
request.PreAuthenticate = true;
CredentialCache ccache = new CredentialCache();
ccache.Add(new Uri(""), "Basic",
new NetworkCredential("your-username", "your-password"));
request.Credentials = ccache;
WebProxy myproxy = new WebProxy("", 13129);
myproxy.BypassProxyOnLocal = true;
request.Proxy = myproxy;
request.Method = "GET";

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Encoding enc = System.Text.Encoding.GetEncoding(1252);
StreamReader loResponseStream = new
StreamReader(response.GetResponseStream(), enc);

string responseString = loResponseStream.ReadToEnd();


If successful, the output is the body of If not successful, the error message is displayed. You may want to store username/password in the application config instead of hard-coding them.