I am using the above object to different POST and GET request. Basically I am downloading a file. I want to download about 10 different files.
However I want to be able to close the connetion which I know is staying open even when i do this.
Expand|Select|Wrap|Line Numbers
- WebProxy proxy = new WebProxy(m_proxyServer, 8080);
- //We do a GET to retrieve the ASP Session ID, and Viewstate and Event attributes states which is set in the reponse
- WebRequest objRequestGet = HttpWebRequest.Create(m_URL);
- objRequestGet.Proxy = proxy;
- ((HttpWebRequest)objRequestGet).UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)";
- objRequestGet.Method = "GET";
- WebHeaderCollection headers = null;
- using (HttpWebResponse objResponseGet = (HttpWebResponse)objRequestGet.GetResponse())
- {
- headers = objResponseGet.Headers;
- StreamReader reader = new StreamReader(objResponseGet.GetResponseStream());
- html = reader.ReadToEnd();
- objResponseGet.Close();
- reader.Close();
- }