This will be a long post, but I figure you'll do better with more information than with less.
The general questions:
How do I set a .NET 2.0 (C#, if it matters) project to use the user's default proxy settings? Since I don't have any access to any proxy with authentication required, is there any way to test proxy support?
I have some software that makes calls to a web service. It works perfectly fine in all of my tests. A customer bought it, and it was failing with HTTP error 407 - proxy authentication required.
I needed to learn about .NET and proxy support. I found an outdated msdn article here
. It tells me the process that .NET 2.0 goes through to figure out proxy settings.
In what little I can find on the web, I've been very surprised that WebRequest doesn't automatically look at your proxy settings. StackOverflow
shows a way that isn't overly inconvenient - simply setting the following in your app.config:
<proxy autoDetect="true" />
Obviously, if this was the perfect solution, I'd question why Microsoft doesn't set proxy autoDect to true as the default.
But it wasn't the perfect solution. I sent the new application to my customer, and he reported that he got a timeout error. I'm guessing that some part of the proxy autodetection timed out, so the whole sequence failed.
I like the idea of fixing it in the app.config rather than in the C# code directly, so I tried removing the autodetect setting and instead using the useSystemDefault setting, (i.e.)
<proxy useSystemDefault="True" />
I would be fairly certain that this should work, but the customer reported that the WebRequest again returned a timeout error.
It is extremely possible that he didn't run the newest program I've sent him
. He's a regular user, not a programmer, but I don't know any other way to work on the proxy issue other than through him. I can ask him to uninstall and reinstall the latest, just to be sure, but he's now out of his office until Monday.
Over the weekend, I'd like to come up with one final test for him - i.e., one that works.
I know that I can also rewrite all the WebRequests to include a Proxy setting, such as this example on stackoverflow
. Since there are several web requests, I've been reluctant to try that, unless I was certain of what proxy settings to use.
If I could unit test this on my own, I'd be ok with shooting in the dark and playing trial and error until I got it working, but having to send each test to a user and having each test fail is making me look worse and worse.
I know the customer can surf the web ok, so he has his web-browser's proxy set up correctly.
Does anyone have a recommendation as to how I can do my own testing? I need to be behind a proxy that requires authentication. I've considered using web-anonymizers, but they don't require authentication.
Does anyone have any experience in this and can tell me the proper way to set the proxy?
What's the difference between WebRequest.DefaultWebProxy
xy? The msdn documentation
(yes, I know this if for .NET 4.0. The documentation for earlier versions says far less, which is part of my confusion.) says that DefaultWebProxy checks the app.config then the IE proxy settings while GetSystemWebProxy only checks the IE proxy settings.
What happens if the user is using a different browser? Do all the proxy settings occur in the same place in the registry, or can it be that his firefox runs fine and his IE is not set up properly?
That's a torrent of questions, but all highly related. If anyone feels this is too much, I'm happy to branch it off into separate questions.
Thanks for reading this, and thanks in advance for any help you can offer.