Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
749 views
Welcome To Ask or Share your Answers For Others

1 Answer

try setting the proxy to an empty WebProxy, ie:

request.Proxy = new WebProxy();

This should create an empty proxy.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...