connect to website using a free proxy server programmatically
.net, asp.net, c#, proxy
Solution
Understanding of zend2 works, you can populate an url like this :
http://zend2.com/bro.php?u=http%3A%2F%2Fwww.google.com&b=12&f=norefer
for browsing google.
I C#, build the url like this :
string targetUrl = "http://www.google.com";
string proxyUrlFormat = "http://zend2.com/bro.php?u={0}&b=12&f=norefer";
string actualUrl = string.Format(proxyUrlFormat, HttpUtility.UrlEncode(targetUrl));
// Do something with the proxy-ed url
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new Uri(actualUrl));
HttpWebResponse resp = req.GetResponse();
string content = null;
using(StreamReader sr = new StreamReader(resp.GetResponseStream()))
{
content = sr.ReadToEnd();
}
Console.WriteLine(content);
Problem
I need to connect to a website using a proxy server. I can do this manually, for example I can use the online proxy `http://zend2.com` and then surf to `www.google.com`. But this must be done programmatically. I know I can use `WebProxy` class but how can I write a code so a proxy server can be used? Anyone can give me a code snippet as example or something? thanks