WebClient and proxies in .NET 1.1

by Jörg Jooss 24. September 2005 05:11

The .NET 2.0 BCL includes some significant enhancements for System.Net.WebClient, like async I/O, easy access to response headers, proxy handling…

Many of these advanced features in .NET 1.1 can only be used by programming directly with System.Net.HttpWebRequest and System.Net.HttpWebResponse. But in order to use a proxy server for your HTTP request, you don't need to do this. Even though there's no Proxy property in WebClient in .NET 1.1, you can still use a proxy through configuration (machine.config – messy) or through code with System.Net.GlobalProxySelection.Select. Just set the proxy before using your WebClient instance.

   1:  GlobalProxySelection.Select = new WebProxy("http://www-proxy.t-online.de:80", true);
   2:  WebClient client = new WebClient();
   3:  byte[] bytes = client.DownloadData("http://www.google.com/search?q=ASP.NET");

Tags:

.NET

Comments (1) -

okey oyna
okey oyna
11/26/2009 10:22:35 AM #

yess or through code with System.Net.GlobalProxySelection.Select. Just set the proxy before using your WebClient instance.

Comments are closed

Page List

RecentPosts

Disclaimer

The posts on this weblog are provided "AS IS" with no warranties, and confer no rights. The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

 

© Copyright 2010, Jörg Jooss