Search code examples
c#httpwebrequest

How to use http post with proxy support in c#


How to use http post with proxy support in c# and multipart form data upload method


Solution

  • This post by Brian Grinstead explains how you can do just that.

    For proxy support, you only need to pass a Proxy setting to HttpWebRequest. So, in the above example, you would change:

    HttpWebRequest request = WebRequest.Create(postUrl) as HttpWebRequest;
    

    To:

    string MyProxyHostString = "192.168.1.200";
    int MyProxyPort = 8080;
    
    HttpWebRequest request = WebRequest.Create(postUrl) as HttpWebRequest;
    request.Proxy = new WebProxy (MyProxyHostString, MyProxyPort);