O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Use Custom Error Pages

Problem

You want to show a custom error page when an unhandled exception or HTTP error occurs.

Solution

Specify a custom error page using the <customErrors> element in the web.config file for the application.

Discussion

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required