Detect and handle Request Timeout

G

Guest

Hi,

I'm wondering how I can find out when a request timeout has occurred and
handle it programmatically.

Here's is what I have so far:

// This handler is added to the web application's Error event
// somewhere else with this code:
// this.Error += new EventHandler( D2LWebApp_Error );
private void WebApp_Error( object sender, EventArgs e ) {
Exception exception = Server.GetLastError();
HttpException he = exception as HttpException;

if( he != null && string.Compare( he.Message, "Request timed out." ) == 0
) {
// handle the timeout somehow
}
}

This codes does work and can detect the timeout for me. However, I'm not
thrilled about relying on a string compare with the exception message!!!

Does anyone know of a better way to do this?

Thanks!
Brian.

ps - I know about the ErrorCode property of HttpException, but when a
timeout happens, it is set to -2147467259. I don't think that this number is
specific to timeout, but is a more general error code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top