R
Roy Chastain
The following is code from the HttpWebRequest.KeepAlive Property documentation
HttpWebRequest myHttpWebRequest2 =
(HttpWebRequest)WebRequest.Create("http://www.contoso.com");
myHttpWebRequest2.Connection="Close";
// Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable.
HttpWebResponse myHttpWebResponse2 =
(HttpWebResponse)myHttpWebRequest2.GetResponse();
// Release the resources held by response object.
myHttpWebResponse2.Close();
The following is my code
wreq = (HttpWebRequest)(WebRequest.Create("http://roy"));
wreq.Connection = "Close";
wresp = (HttpWebResponse)(wreq.GetResponse());
wresp.Close();
The following is the exception (occurs on the GetResponse)
An unhandled exception of type 'System.ArgumentException' occurred in system.dll
Additional information: Keep-Alive and Close may not be set with this property.
1) - Is the example wrong?
2) - What procedure should I use to 'close' my connection to a web server?
Thanks for any insight.
HttpWebRequest myHttpWebRequest2 =
(HttpWebRequest)WebRequest.Create("http://www.contoso.com");
myHttpWebRequest2.Connection="Close";
// Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable.
HttpWebResponse myHttpWebResponse2 =
(HttpWebResponse)myHttpWebRequest2.GetResponse();
// Release the resources held by response object.
myHttpWebResponse2.Close();
The following is my code
wreq = (HttpWebRequest)(WebRequest.Create("http://roy"));
wreq.Connection = "Close";
wresp = (HttpWebResponse)(wreq.GetResponse());
wresp.Close();
The following is the exception (occurs on the GetResponse)
An unhandled exception of type 'System.ArgumentException' occurred in system.dll
Additional information: Keep-Alive and Close may not be set with this property.
1) - Is the example wrong?
2) - What procedure should I use to 'close' my connection to a web server?
Thanks for any insight.