G
Guest
I appreciate anyone's insight on this as I am new to web programming with .NET.
I have a simple method which I use to send various HTTP requests to a web
server (snippet below). On the first several invocations, the debugger will
actually stop in the catch block.
However, after a number of invocations (variant) the program just hangs on
waiting for the GetResponse(). I would expect the timeout/Webexception to
occur. In monitoring the traffic on the webserver, the requests are coming
in and the server appears to be responding appropriately.
On an additional note, if I comment out the explicit setting of the timeout
to 100 ms (from what I read in the WROX book, default is 100,000 anyway),
then the application never steps into the catch block.
bool sendWebRequest(string URIstring)
{
WebRequest webReq = WebRequest.Create(URIstring);
webReq.Timeout = 100;
try
{
WebResponse webResp = webReq.GetResponse();
return true;
}
catch (WebException e)
{
return false;
}
}
I have a simple method which I use to send various HTTP requests to a web
server (snippet below). On the first several invocations, the debugger will
actually stop in the catch block.
However, after a number of invocations (variant) the program just hangs on
waiting for the GetResponse(). I would expect the timeout/Webexception to
occur. In monitoring the traffic on the webserver, the requests are coming
in and the server appears to be responding appropriately.
On an additional note, if I comment out the explicit setting of the timeout
to 100 ms (from what I read in the WROX book, default is 100,000 anyway),
then the application never steps into the catch block.
bool sendWebRequest(string URIstring)
{
WebRequest webReq = WebRequest.Create(URIstring);
webReq.Timeout = 100;
try
{
WebResponse webResp = webReq.GetResponse();
return true;
}
catch (WebException e)
{
return false;
}
}