S
Scott Wegner
Hi All,
Just a quick question. I'm performing a simple web query with a timeout
using the WebRequest.GetResponse() method. I was wondering if it is safe to
use the same WebRequest to query after it has timed out once. In the remarks
for the HttpWebRequest.GetResponse() method
(http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.getresponse.aspx):
Multiple calls to GetResponse return the same response object; the request
is not reissued.
However, when the a request times out, an exception is thrown. I just want
to make sure I can use the same WebRequest to retry the query, and that the
exception will not be cached and returned promptly.
My code looks something like this:
WebRequest request = WebRequest.Create(MY_URL);
request.Timeout = MY_TIMEOUT;
WebResponse response = null;
int numTries = 0;
while ((response == null) && (numTries < RETRY_LIMIT))
try { response = request.GetResponse(); }
catch(WebException ex) { numTries++; }
Thanks in advance.
Just a quick question. I'm performing a simple web query with a timeout
using the WebRequest.GetResponse() method. I was wondering if it is safe to
use the same WebRequest to query after it has timed out once. In the remarks
for the HttpWebRequest.GetResponse() method
(http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.getresponse.aspx):
Multiple calls to GetResponse return the same response object; the request
is not reissued.
However, when the a request times out, an exception is thrown. I just want
to make sure I can use the same WebRequest to retry the query, and that the
exception will not be cached and returned promptly.
My code looks something like this:
WebRequest request = WebRequest.Create(MY_URL);
request.Timeout = MY_TIMEOUT;
WebResponse response = null;
int numTries = 0;
while ((response == null) && (numTries < RETRY_LIMIT))
try { response = request.GetResponse(); }
catch(WebException ex) { numTries++; }
Thanks in advance.