Creating global error handling is a good idea that allows your site to catch unexpected errors, which may occur at the application level. In order to accomplish this task, you will need to place code in the Application_Error method of the Global.asax.cs file.
//Global.asax.cs
protected void Application_Error(Object sender, EventArgs e)
{
//Error has occurred - redirect the user to our error page. Response.Redirect("Error.aspx");
}
This is a very simple example that will redirect a user to our Error.aspx web page, if any unhandled exception occurs. Although we're simply doing a redirect here, we could have utilized this method to notify the web administrator by email, with the details of the error, page, time, etc, etc.
If you're looking for a way to email through your web application, then be sure to check out my blog on how to create an Automated Email System.