You want to show a custom error page when an unhandled exception or HTTP error occurs.
Specify a custom error page using the <customErrors> element in the web.config file for the application.
Custom error pages allow you to specify a page that will be returned to the user if an unhandled .NET exception occurs in your page code. Custom error pages aren’t a replacement for good error handling; they just allow your application to maintain its professional appearance in the event of an unexpected error. Custom error pages can also be used to catch HTTP errors (for example, if the user requests a page that does not exist) and return descriptive error pages.
You can define custom errors at the virtual directory ...