views:

32

answers:

2

I am trying to use FtpWebRequest.Proxy and have it set to GlobalProxySelection.GetEmptyWebProxy() however i get a compliler warning

Warning 1 'System.Net.GlobalProxySelection' is obsolete: '"This class has been deprecated. Please use WebRequest.DefaultWebProxy instead to access and set the global default proxy. Use 'null' instead of GetEmptyWebProxy. http://go.microsoft.com/fwlink/?linkid=14202"'

it reccomends to use null, but from FtpWebRequest.Proxy's page under the execptions section it says

ArgumentNullException - This property cannot be set to null.

What is the correct thing to do?

+1  A: 

You're right. That's confusing.

The answer appears to be to use the WebRequest.DefaultWebProxy property.

John Saunders
But I do not want to use the default web proxy. The proxy that is set up as default is for getting out of our internal network. the ftp resource I am accessing is on the internal network. If I use the proxy I must cross a 5Mbit link (the server is rate limited), where if I stay internal I have 1Gbit transfers.
Scott Chamberlain
+1  A: 

That is confusing. But looking at the decompiled code for the setter of that property it doesn't look like it will throw that exception if you set it to null. I'd suggest the documentation is out of date and set it to null. It should be quickly apparent whether you get an exception or not...

Chris
I ran a test with it null. No exception. I guess the MSDN is out of date.
Scott Chamberlain