Geeks With Blogs

Tim Huffam Dotting the I and crossing the T of I.T.

The following error occured when trying to open a web page (ASP.NET) that was doing an HttpRequest.

"The underlying connection was closed: The remote name could not be resolved."

This is usually caused because the ASP.NET app is on a network that is using a proxy server - and as ASP.NET does not run as a user account, it does not have access to the proxy settings in the registry.

To resolve add the following section to your web.config file.

<defaultProxy>
     <proxy
          usesystemdefault = "false"
          proxyaddress="http://proxyserver:port"
          bypassonlocal="true"
     />
</defaultProxy>

Note that this must be placed within a <system.net> section (not system.web!).

MS have a kb article on it here.

HTH

Tim

Posted on Thursday, February 9, 2006 9:20 AM C# .NET , OS/Networking/Misc Apps , ASP.NET , IIS | Back to top


Comments on this post: Error: The underlying connection was closed: The remote name could not be resolved. When doing HttpRequest from ASP.NET.

# re: Error: The underlying connection was closed: The remote name could not be resolved. When doing HttpRequest from ASP.NET.
Requesting Gravatar...
Is this the way we are supposed to define the proxy:

<configuration>
<appSettings>
<add key="key1" value="val1"/>
</appSettings>

<system.net>
<defaultProxy>
<proxy
usesystemdefault = "false"
proxyaddress="http://proxyserver:port"
bypassonlocal="true"
/>
</defaultProxy>
</system.net>

<system.web>
</system.web>
</configuration>
Left by Nav on Mar 08, 2007 5:47 AM

# re: Error: The underlying connection was closed: The remote name could not be resolved. When doing HttpRequest from ASP.NET.
Requesting Gravatar...
i added this to web.config but the same error is coming.we are using this in episerver
Left by bhasjar on Aug 09, 2007 2:23 AM

# re: Error: The underlying connection was closed: The remote name could not be resolved. When doing HttpRequest from ASP.NET.
Requesting Gravatar...
i also tried addin this but couldnt resolve the issue.
Left by saikat on Sep 06, 2007 6:09 AM

# re: Error: The underlying connection was closed: The remote name could not be resolved. When doing HttpRequest from ASP.NET.
Requesting Gravatar...
i am too geting the same error
Left by nisheed_m@rediffmail.com on Oct 22, 2007 1:59 AM

# re: Error: The underlying connection was closed: The remote name could not be resolved. When doing HttpRequest from ASP.NET.
Requesting Gravatar...
WebProxy proxy = New WebProxy("<your proxy address>", port num);

WebClient client = New WebClient;
client.proxy = proxy;


After you typed the above code, "client" object can get the external web information throught your proxy.
Left by Ben on Nov 15, 2007 9:47 PM

# re: Error: The underlying connection was closed: The remote name could not be resolved. When doing HttpRequest from ASP.NET.
Requesting Gravatar...
Hey Thank you very much.
Left by Himanshu on Nov 28, 2008 7:39 PM

Your comment:
 (will show your gravatar)


Copyright © Tim Huffam | Powered by: GeeksWithBlogs.net