Hacker Forums

C# WebClient and WebProxy example code.


by The Uni-Hacker on Aug.28, 2008, under Programming

The following is example source code written in C# on how to establish a web site connection using the WebClient object and the WebProxy object.


WebProxy p = null;
ICredentials cred;
cred = new NetworkCredential("username", "password");
p = new WebProxy("proxy.server.com:port", true, null, cred);
WebRequest.DefaultWebProxy = p;

WebClient wc = new WebClient();
wc.Proxy = p;
string data = wc.DownloadString(url);

:,
Click the .NET+C#+ to view the picture in full size.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...