The goals of exception handling in this application are quite simple:
All exceptions should be caught and displayed to the user in one page. Details about the exception should not be shown to users.
The system should automatically send an e-mail with details about the exception that occurred, the user who caused the exception, and the call stack.
The system should log the details of the exception to the event log in case the e-mail failed to be sent.
The system should allow an administrator to control who receives an e-mail without having to recompile and deploy the application.
Start by defining the common page that will be used to show users a message:
Add a new page to the PaidTimeOffUI project that uses the PaidTimeOff master page and name it ErrorPage.aspx. Only text should be displayed to users, so we won't put any code in this page that could potentially cause another error to occur because that would make it difficult to track down the original error. You can add text that says something to the effect that a problem has occurred and that the appropriate personnel have been notified. Since this page uses the PaidTimeOff master page, change the code-behind so the partial class inherits from BasePage, and then override the MenuItemName method. Change this method so it returns "Home." This will display the page with the Home tab highlighted.
Turn custom error handling on in the web.config file:
<customErrors mode="RemoteOnly" defaultRedirect="ErrorPage.aspx"> </customErrors> ...