Does customErrors mode="Off" influence the behavior of try-catch blocks or the Application_Error event in Global.asax?

Responsive Ad Header

Question

Grade: Education Subject: Support
Does customErrors mode="Off" influence the behavior of try-catch blocks or the Application_Error event in Global.asax?
Asked by:
118 Viewed 118 Answers
Responsive Ad After Question

Answer (118)

Best Answer
(869)
No, `customErrors mode="Off"` primarily dictates how *unhandled* exceptions are presented to the client browser, not how exceptions are processed internally by the application. * **`try-catch` blocks**: These blocks will still catch and handle exceptions as designed, preventing them from becoming unhandled exceptions. `customErrors` settings only apply if an exception *escapes* a `try-catch` block. * **`Application_Error` event**: This event in `Global.asax` will still fire for all unhandled exceptions (even when `mode="Off"`). It provides an opportunity to log the error, redirect, or perform other custom handling *before* the `customErrors` configuration dictates the final presentation to the user. The `customErrors` setting determines what the user sees *after* `Application_Error` finishes, assuming the error is not explicitly marked as handled there.