473,320 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Page_Error versus Application_Error Error Handling??

Can anyone give me a good reason to use BOTH application scope Page_Error
and the page scope Page_Error when trapping errors in a web application? Is
there any real benefit to using the Page_Error if you are already capturing
errors in Application_Error? Also, if you have any links to discussions
about when to use which function it would be helpful.
Nov 19 '05 #1
6 4540
In Page_Error you can redirect the user someplace, or just change the output
of the page to some user friendly error message.

In Application_Error, all you can do is log the error somehow. You can't do
anything with the request.

I would use Application_Error for those cases where the page isn't handling
the error for some reason, as a last resort to log the error. If a page can
handle its own errors and gracefully deal with them, it should do so in
Page_Error.

"Matt" <md*******@nospam.com> wrote in message
news:Oz**************@TK2MSFTNGP09.phx.gbl...
Can anyone give me a good reason to use BOTH application scope Page_Error
and the page scope Page_Error when trapping errors in a web application?
Is there any real benefit to using the Page_Error if you are already
capturing errors in Application_Error? Also, if you have any links to
discussions about when to use which function it would be helpful.

Nov 19 '05 #2
Good question. And subsequently not a really good answer.

"It depends".

I know that isn't what you wanted to hear, but let me explain. Page and
Application two different scopes (obviously). And so with that in mind,
your Exceptions would occur in one and/or the other scope.

How far up the stack do you want to catch errors?

Clint Hill
H3O Software
http://www.h3osoftware.com
Matt wrote:
Can anyone give me a good reason to use BOTH application scope Page_Error
and the page scope Page_Error when trapping errors in a web application? Is
there any real benefit to using the Page_Error if you are already capturing
errors in Application_Error? Also, if you have any links to discussions
about when to use which function it would be helpful.

Nov 19 '05 #3
There are times where you can compensate for an error at the page level
rather than send it up to a generic application level handler. It is all a
matter of scope. As much as possible, try to handle things at the smallest
scope you can.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Matt" wrote:
Can anyone give me a good reason to use BOTH application scope Page_Error
and the page scope Page_Error when trapping errors in a web application? Is
there any real benefit to using the Page_Error if you are already capturing
errors in Application_Error? Also, if you have any links to discussions
about when to use which function it would be helpful.

Nov 19 '05 #4
Actually you can redirect and do whatever you like with the Request
inside of Application_Error. You can use the Response.Redirect or grab
the HttpContext.Current and do whatever.

Clint Hill
H3O Software
http://www.h3osoftware.com
Marina wrote:
In Page_Error you can redirect the user someplace, or just change the output
of the page to some user friendly error message.

In Application_Error, all you can do is log the error somehow. You can't do
anything with the request.

I would use Application_Error for those cases where the page isn't handling
the error for some reason, as a last resort to log the error. If a page can
handle its own errors and gracefully deal with them, it should do so in
Page_Error.

"Matt" <md*******@nospam.com> wrote in message
news:Oz**************@TK2MSFTNGP09.phx.gbl...
Can anyone give me a good reason to use BOTH application scope Page_Error
and the page scope Page_Error when trapping errors in a web application?
Is there any real benefit to using the Page_Error if you are already
capturing errors in Application_Error? Also, if you have any links to
discussions about when to use which function it would be helpful.


Nov 19 '05 #5
Well, all we want to do is catch any error that the app experiences, write
the error stack, the page name, and other information to the database, and
send an email to the developers. We already handle some small stuff with
try/catches and appropriate messages to the user within applications. This
is for data connection problems, 404's, etc. that wouldn't be the user's
fault.

I was under the impression that you could do it piecemeal in each page, OR
consolidate it in the Application_Error function. Any error that doesn't
get caught in the Page_Error, or any error that IS caught but isn't cleared,
gets caught by the Application_Error in the global.

Since we're just capturing each error for our notifications purposes and not
having different actions for each page, I thought that the best thing to do
would be to do this once in the Application_Error. The error gets put in
the database, the email gets sent, and the user is shown an error page as
assigned in the CustomErrors node in the web.config.

Other developers here feel that we should have both the Application_Error
AND the Page_Error in use; but they are not talking about having specific
Page_Errors for individual pages. They are talking about putting a
catch-all Page_Error in our custom Page base class, from which all our pages
inherit. The justification that was offered for this is that they say there
are errors that aren't necessarily 'application errors' but are actually
'page errors', and that these errors will not be trapped by the
Application_Error function... but they will be caught by the Page_Error
function. I tend to believe that isn't true; any .NET error will be caught
by the Application_Error (since the application is actually the entire
website); and that in this situation, using both the Application_Error and
the Page_Error is redundant.

Am I wrong? If so, could someone give me an example of some C# code that
could cause an error that would be trapped with the Page_Error function but
not by the Application_Error function?

"Clint Hill" <cl********@nospamath3osoftware.com> wrote in message
news:OE****************@TK2MSFTNGP09.phx.gbl...
Good question. And subsequently not a really good answer.

"It depends".

I know that isn't what you wanted to hear, but let me explain. Page and
Application two different scopes (obviously). And so with that in mind,
your Exceptions would occur in one and/or the other scope.

How far up the stack do you want to catch errors?

Clint Hill
H3O Software
http://www.h3osoftware.com
Matt wrote:
Can anyone give me a good reason to use BOTH application scope Page_Error
and the page scope Page_Error when trapping errors in a web application?
Is there any real benefit to using the Page_Error if you are already
capturing errors in Application_Error? Also, if you have any links to
discussions about when to use which function it would be helpful.

Nov 19 '05 #6
Is there any reason, in doing generic error logging, to use the Page_Error
(unless you are doing something specific to that page)?
"Cowboy (Gregory A. Beamer) - MVP" <No************@comcast.netNoSpamM> wrote
in message news:20**********************************@microsof t.com...
There are times where you can compensate for an error at the page level
rather than send it up to a generic application level handler. It is all a
matter of scope. As much as possible, try to handle things at the smallest
scope you can.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Matt" wrote:
Can anyone give me a good reason to use BOTH application scope Page_Error
and the page scope Page_Error when trapping errors in a web application?
Is
there any real benefit to using the Page_Error if you are already
capturing
errors in Application_Error? Also, if you have any links to discussions
about when to use which function it would be helpful.

Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Leo R | last post by:
Hi all, If an error occurs in an aspx-page, you can configure the web.config in a way that the user automatically navigates to a certain page (e.g. error.aspx). My question: is it possible to...
0
by: Krissy | last post by:
Hi all, I am practically tearing my hair out here!! In my global.asax file, I have in the Application_error() sub a call to a sub in a library file. What I aim to do is to log the error in...
4
by: Sandy | last post by:
Hello - I read an interesting article on the web wherein the author states he doesn't handle too many errors at page level, but handles them at the application level. He further goes on to show...
1
by: Oscar Thornell | last post by:
Hi, I have an ASP.NET page that generates an Exception... The Exception is not caught in the executing method...so it propagates to..the Page_Error event handling method.. In that method the...
4
by: michaeltorus | last post by:
Hi I've written a custom Error handler thingy majig. I create it at the ASP level, and pass it into my business components which catch all errors below that. When an error occurs, my error handler...
3
by: Mr Newbie | last post by:
I'm testing error handling configurations and having some trouble. I created a WebForm called. ErrDefault.aspx and I am trying to use the Page error attribute to force the redirection to a custom...
2
by: tshad | last post by:
This has been driving me crazy. I have been trying to get the error handling working on my system and can get parts of it working and others won't work at all. I found that you can't access...
6
by: RonL | last post by:
What is the recommended best technique for handling errors/exceptions in ASP.Net. I've read about the following techniques: 1. Try/Catch 2. Page_Error 3. Application_Error in the...
2
by: rpradeepa | last post by:
Hi, For handling the errors globally, i did some thing in web configuration file and global.asax file In web configuration <customErrors mode="Off" defaultRedirect="Err.htm"></customErrors> ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.