This article explains how to do custom error handling using ASP.NET
Custom Error Handling Using ASP.NET (c-sharpcorner.com)