Monday, September 10, 2007


I needed a way to grab some content from a remote site. The following code worked the best. You may not need to specify a proxy as I have.

System.Net.WebClient wc = new System.Net.WebClient();
string proxyURL = ConfigurationManager.AppSettings["ProxyURL"];
string proxyCredUserName = ConfigurationManager.AppSettings["ProxyUserName"];
string proxyCredPassword = ConfigurationManager.AppSettings["ProxyPassword"];
System.Net.WebProxy proxy = new System.Net.WebProxy(proxyURL);
System.Net.NetworkCredential cred = new System.Net.NetworkCredential(proxyCredUserName, proxyCredPassword, domain);
proxy.UseDefaultCredentials = true;
proxy.Credentials = cred;
wc.Proxy = proxy;
chartImage = wc.DownloadData(chartImageURL);