-
November 27th, 2004, 06:52 AM
#1
request.GetResponse() timeout
Hi
I have a button that runs this code:
Code:
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri("http://www.vg.no"));
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
The first time I run it, everything is fine. Same with the secound time, but after 3-4 times, I get a timeout on the secound line! Sometimes, I can run the code 7-8 times, but normally it stopps the 3rd time.
Anyone have any idea why??
-
November 27th, 2004, 07:20 AM
#2
Re: request.GetResponse() timeout
Do you get similar timeouts when you use Internet Explorer?
-
November 27th, 2004, 09:23 AM
#3
Re: request.GetResponse() timeout
How do I find out? I have tried refreshing the page multiple times, but no timeouts... (means that everything seems to be working fine in explorer, opera and firefox)
This is not the only page, btw. I get the same problem no matter what page I choose. Tried with several newspapers, google, hotmail, ..., all with the same result. (Number of times before it hangs may change)
Last edited by Nightfall; November 27th, 2004 at 10:21 AM.
-
November 28th, 2004, 04:53 AM
#4
Re: request.GetResponse() timeout
Come on... I can't beleave I am the only one with this problem! The code is simple... Can someone else plz test it, and tell me if they get the same problem?
I am in a little hurry, so today would be great, but if there ain't any solution posted below, plz answer no matter if it is weeks since I posted this. I will post if I solve the problem
-
November 29th, 2004, 10:48 AM
#5
Re: request.GetResponse() timeout
Problem solved...
Forgot to close the response-object...
-
December 21st, 2004, 08:14 AM
#6
Re: request.GetResponse() timeout
I had a similar problem and I used the Close() function and it still gave me problems. So I used the 'using' keyword like this:
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri("http://www.vg.no"));
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
// do something with response here...
}
This calls the Dispose function after it leaves the curly braces which in turn, I assume, calls the Close() function among some other clean up stuff that is not well documented.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|