How to remove proxy from WebRequest and leave DefaultWebProxy untouched

Posted by Elephantik on Stack Overflow See other posts from Stack Overflow or by Elephantik
Published on 2009-10-13T12:19:08Z Indexed on 2010/03/27 9:23 UTC
Read the original article Hit count: 234

Filed under:
|
|

I use FtpWebRequest to do some FTP stuff and I need to connect directly (no proxy). However WebRequest.DefaultWebProxy contains IE proxy settings (I reckon).

WebRequest request = WebRequest.Create("ftp://someftpserver/");
// request.Proxy is null here so setting it to null does not have any effect
WebResponse response = request.GetResponse();
// connects using WebRequest.DefaultWebProxy

My code is a piece in a huge application and I don't want to change WebRequest.DefaultWebProxy because it is global static property and it can have adverse impact on the other parts of the application.

Any idea how to do it?

© Stack Overflow or respective owner

Related posts about web-development

Related posts about c#