By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,771 Members | 1,448 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,771 IT Pros & Developers. It's quick & easy.

Trapping Http 500 error

P: n/a
Hi,

I have an ASP.Net 1.1 web services project, occasionally it will encounters
500 or other errors, as you know 500 error could be a result of all kind of
problems. Instead of letting IIS display the error, can I trap the error
using ASP.Net and customize the error page or silently handle the error?

TIA
Jan 24 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Yes, you can trap the errors. For that you would use:

catch (WebException wex)
{
HttpStatusCode httpStatus = HttpStatusCode.NotFound;

if (wex.Response is HttpWebResponse)
httpStatus = ((HttpWebResponse)wex.Response).StatusCode;
}

Hope it helps.

--
Regards,
Robson Siqueira
Enterprise Architect
"Raymond Du" <rd**@yahoo.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi,

I have an ASP.Net 1.1 web services project, occasionally it will
encounters 500 or other errors, as you know 500 error could be a result of
all kind of problems. Instead of letting IIS display the error, can I trap
the error using ASP.Net and customize the error page or silently handle
the error?

TIA

Jan 24 '07 #2

P: n/a
Thank you for your response.

Where should I put the code snippet in? In the page_load of every .aspx
files? I doubt the page_load get called when 500 error happens.

Thanks Again
"Robson Siqueira" <ro****@robsonfelix.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Yes, you can trap the errors. For that you would use:

catch (WebException wex)
{
HttpStatusCode httpStatus = HttpStatusCode.NotFound;

if (wex.Response is HttpWebResponse)
httpStatus =
((HttpWebResponse)wex.Response).StatusCode;
}

Hope it helps.

--
Regards,
Robson Siqueira
Enterprise Architect
"Raymond Du" <rd**@yahoo.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>Hi,

I have an ASP.Net 1.1 web services project, occasionally it will
encounters 500 or other errors, as you know 500 error could be a result
of all kind of problems. Instead of letting IIS display the error, can I
trap the error using ASP.Net and customize the error page or silently
handle the error?

TIA


Jan 24 '07 #3

P: n/a
You should create a global error handling. A very good article detailing
that can be found at http://www.developer.com/net/asp/article.php/961301.

I hope it helps.

--
Regards,
Robson Siqueira
Enterprise Architect
"Raymond Du" <rd**@yahoo.comwrote in message
news:OS**************@TK2MSFTNGP06.phx.gbl...
Thank you for your response.

Where should I put the code snippet in? In the page_load of every .aspx
files? I doubt the page_load get called when 500 error happens.

Thanks Again
"Robson Siqueira" <ro****@robsonfelix.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>Yes, you can trap the errors. For that you would use:

catch (WebException wex)
{
HttpStatusCode httpStatus = HttpStatusCode.NotFound;

if (wex.Response is HttpWebResponse)
httpStatus =
((HttpWebResponse)wex.Response).StatusCode;
}

Hope it helps.

--
Regards,
Robson Siqueira
Enterprise Architect
"Raymond Du" <rd**@yahoo.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>>Hi,

I have an ASP.Net 1.1 web services project, occasionally it will
encounters 500 or other errors, as you know 500 error could be a result
of all kind of problems. Instead of letting IIS display the error, can I
trap the error using ASP.Net and customize the error page or silently
handle the error?

TIA



Jan 24 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.