I'm writing a .NET application which is supposed to post data to another .NET application.
I use the following code to request the login page
WebProxy proxy = new WebProxy("http://proxy:80/", true);
HttpWebRequest webRequest = WebRequest.Create(LOGIN_URL) as HttpWebRequest;
//proxy.Credentials = new NetworkCredential("myusername", "mypassword", "domain");
// webRequest.Proxy = proxy;
webRequest.Proxy = WebRequest.DefaultWebProxy;
StreamReader responseReader = new StreamReader
(webRequest.GetResponse().GetResponseStream());
string responseData = responseReader.ReadToEnd();
but it fails on this line
StreamReader responseReader = new StreamReader
(webRequest.GetResponse().GetResponseStream());
with the error message :
System.Net.WebException: The underlying connection was closed: The connection was
closed unexpectedly.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…