473,386 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

HTTPWebRequest/HTTPWebResponse - Cant close connection

Hi,

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
  1. WebProxy proxy = new WebProxy(m_proxyServer, 8080);
  2.                              //We do a GET to retrieve the ASP Session ID, and Viewstate and Event attributes states which is set in the reponse
  3.  
  4.                 WebRequest objRequestGet = HttpWebRequest.Create(m_URL);
  5.                 objRequestGet.Proxy = proxy;
  6.                 ((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)";
  7.                 objRequestGet.Method = "GET";
  8.  
  9.                 WebHeaderCollection headers = null;
  10.                 using (HttpWebResponse objResponseGet = (HttpWebResponse)objRequestGet.GetResponse())
  11.                 {
  12.                     headers = objResponseGet.Headers;
  13.                     StreamReader reader = new StreamReader(objResponseGet.GetResponseStream());
  14.                     html = reader.ReadToEnd();
  15.                     objResponseGet.Close();
  16.                     reader.Close();                                              
  17.                 }
  18.  
How do i close the connection?
Jul 10 '08 #1
1 1670
Plater
7,872 Expert 4TB
In your request, if you add the header: "Connection: Close" does it help?
Jul 10 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: TJO | last post by:
Can someone at MS please reply to this. I am trying to post data so a web form via ssl with the following code. I keep getting this error: "The underlying connection was closed: Could not...
9
by: Mike Cronin via DotNetMonster.com | last post by:
Hi there, Can anyone tell me what level of encryption is used when making an HTTPS POST request through an instance of the System.Net.HttpWebRequest object? Thanks much in advance! Mike...
0
by: TJO | last post by:
Can someone at MS please reply to this. I am trying to post data so a web form via ssl with the following code. I keep getting this error: "The underlying connection was closed: Could not...
10
by: Mike Cronin via DotNetMonster.com | last post by:
Hi there, Can anyone tell me what level of encryption is used when making an HTTPS POST request through an instance of the System.Net.HttpWebRequest object? Thanks much in advance! Mike...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.