Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 207
monkey_boys Avatar asked Sep 03 '09 10:09

monkey_boys


2 Answers

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);
like image 57
Druid Avatar answered Oct 22 '22 15:10

Druid


If you need to configue a proxy then you can do so in the .config file:-

<system.net>
  <defaultProxy enabled="true">
    <proxy proxyaddress="http://myproxyserver:8080" bypassonlocal="True"/>
  </defaultProxy>
</system.net>

See this question on form data posting.

like image 23
AnthonyWJones Avatar answered Oct 22 '22 15:10

AnthonyWJones