开发者

WebException error from HttpWebRequest

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 开发者_Go百科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:

  • Proxy Server in between you and the remote server
  • Authentication issues
  • Network outages.

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 to HttpWebRequest.Proxy and adding proxy credentials to HttpWebRequest.Credentials if you need them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜