catching all errors

G

Guest

hey all,
is there a way to catch all errors for my webform without using the
global.asax page?
thanks,
rodchar
 
M

Mark Rae

is there a way to catch all errors for my webform without using the
global.asax page?

Other than surrounding all your code with try...catch, I don't think so...
 
M

Michael Nemtsev

Hello Mark,

BTW, u can handle your exceptions with System.Web.UI.Page.Error even

MR> MR> MR> Other than surrounding all your code with try...catch, I don't think
MR> so...
MR>
---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
A

Annie

Hi Michael,
Can you please explain what mean?
many thanks


Michael Nemtsev said:
Hello Mark,

BTW, u can handle your exceptions with System.Web.UI.Page.Error even

MR> MR>MR> Other than surrounding all your code with try...catch, I don't think
MR> so...
MR> ---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche
 
K

Karl Seguin

That website is TOTALLY AND ABSOLUTELY WRONG. It _WILL_ get corrected during
the next major revision (or help me god...). Well over 90% of the time you
can't handle an actual exception..all you can do is clean up...in which case
you should be using try/finallys and "usings". Your logging code should be
centralized, and the best way to do this is with Global.asax's on error ..

Handling exceptions in global.asax is the CORRECT way to do things.

As was mentioned, you can also catch errors in the page. you can do this by
overriding the OnError method.

protected override void OnError(EventArgs e)
{
...
}

if you put this in a base class and have all your pages inherit from it,
you're good to go.

More on exception hanlding in .NET:
http://codebetter.com/blogs/karlseguin/archive/2006/04/05/142355.aspx

Karl
 
M

Mark Rae

That website is TOTALLY AND ABSOLUTELY WRONG. It _WILL_ get corrected
during the next major revision (or help me god...).

Glad to hear it!

For the record, I wasn't actually recommending following its contents -
quite the reverse... :)
Well over 90% of the time you can't handle an actual exception..all you
can do is clean up...
in which case you should be using try/finallys and "usings".

I couldn't agree more...
Your logging code should be centralized, and the best way to do this is
with Global.asax's on error ..

Again, totally agreed...
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top