I am getting an error like this Can any one tell me the possible reason for these type of exception
unhandled exception of type 'System.Net.WebException' occurred in system.dll
Additional information: The underlying connection was closed: Unable to connect
to the remote server.
Is this related to IIS or any NetworkCredentials to the network classes.
It looks like the connection socket was closed before your computer was able to connect to the remote server. In other words, your outbound connection failed for some reason. I'm guessing you're using an HttpWebRequest, in which case there might be a failure code that could provide some insight. Can you show us how you're setting up the request?
Some Googling turned up this blog post which suggests a few possibilities:
The post notes that .NET uses HTTP 1.1 by default. I've run into some embedded web servers that don't play nicely with 1.1. Try setting
HttpWebRequest.ProtocolVersion
to HTTP 1.0. Also try passing a proxy toHttpWebRequest.Proxy
and adding proxy credentials toHttpWebRequest.Credentials
if you need them.