Tuesday, August 15, 2006

Proxy Frustration

Recently I was getting a proxy authentication error when trying to test a web service. I had created an asp.net 2.0 website that contained a simple form that when submitted, requested information from my web service which was hosted in another domain.

I was running the web site locally in debug mode and could access it without any issues. When I submitted the form (causing the asp.net code to make a request to the web service) I received the following error:

The request failed with HTTP status 407: Proxy Authentication Required

I wasn't specifying any proxy information, so I enlisted an infrastructure guy to help. "You should turn off your proxy information in "Internet Explorer" he told me. "That has nothing to do with it" I replied and proceeded to draw a diagram, explaining that it was the web server that had the problem when trying to access the web service, not me as the client.

He understood what I was trying to tell him, and agreed. "Just turn it off so I can rule it out" he said, and I complied.

Sure enough, removing the proxy settings in my browser fixed the problem. "I'm getting a coffee" my infrastructure friend stated smugly, and walked off.

Obviously my only conclusion is that the web server started by Visual Studio 2005 uses the system proxy settings by default. A quick web search confirmed it:


http://msdn.microsoft.com/vstudio/support/knownIssues/default.aspx

2.22 In .NET Framework 2.0, GlobalProxySelection.Select behaves differently than in version 1.1 when an empty System.Net tag is present in the machine.config file

In version 1.1 of the .NET Framework, specifying an empty System.Net element in the machine.config file, GlobalProxySelection.Select returns an empty web proxy instance indicating that no proxy is to be used. In version 2.0, the new default is that the system proxy settings (same as what is specified in Internet Explorer) will be used in this case.

To resolve this issue

Modify the machine.config file to disable the default proxy as shown below.

<system.net>
<defaultProxy enabled="false" />
</system.net>

Unfortunately this solution didn't work for me and I had to add a proxy exclusion rule to IE. If I find a better solution, I'll post it here.

0 Comments:

Post a Comment

<< Home