Exception Handling Scope

F

Fred Chateau

Can exceptions only be handled in a protected block?

For example, can I globally catch and handle any exception generated from an
ASP.NET page without placing the entire Page_Load event handler code in a
try-catch block?
 
D

Dave Sexton

Hi Fred,

Placing the entire Page_Load event handler in code wouldn't catch all
exceptions that may be thrown by the page. There are many other events that
are raised during the ASP.NET page life cycle and Load is only one of them.

"ASP.NET Life Cycles"
http://msdn2.microsoft.com/en-us/library/ms227435.aspx

Error handling can be configured in the web.config, on the Page level or
handled explicitly in code using either the global.asax file or custom
HttpModules.

Of course, you are encouraged to use judicious error handling on the method
level as well. But don't just catch everything - only catch what you can
handle gracefully.

"Error Handling in ASP.NET Pages and Applications"
http://msdn2.microsoft.com/en-us/library/w16865z6.aspx
 

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

Top