In this tutorial, we will go over how to change and edit how you view custom errors of your web application. In most cases, when you are setting up your ASP.NET application and there is an error in your coding you will get an image similar to the one shown below.


As nice as it is to have a message that tells us there is an error, this tells us nothing. Let’s learn how to fix this page so we can display and control the right error message to help us develop our new ASP.NET site.

Editing your Web.Config file

If you are just getting started with ASP.NET and you see error page for the first time, you may just disregard it. If you read carefully though, it will tell you insert a line of code to activate a nice feature that will highlight the exact line of code that needs to be fixed. In your ASP.NET project (or the root folder where your project is located), you will need to search for and open the Web.Config file. If you started from a template, you may have a pretty long listing of code housed between the <system.web> or you may have a new clean web.config file. Either way, in order to view your custom errors and debug your application, insert the line of coding below between the <system.web> and </system.web> tag:

In some cases, you may have a <customErrors> tag already. In this case just switch the Off to On. Save and refresh your page and you should now see a highlighted section with the error in your code like so:


When editing your customErrors, there are three modes that you can use to trace an error. These modes help decide whether or not an error message will be displayed. Let’s look at them:

  • Off Mode – The Off Mode will display error messages on local and remote server in case of an error.
  • On Mode – The On Mode will display a custom error page with messages on a local and remote server in case of an error. When using this mode, we can show our own custom error messages page for specific errors on a local and remote server.
  • RemoteOnly – The RemoteOnly Mode will display error messages on a remote server only in the case of an error. This is the Default Mode when a customError is not stated and gives us the ability to show our own custom error message page for specific errors on remote servers only.

Wrapping it Up

This is a really nice and helpful feature that can helpful narrow down errors in your code and make you a better programmer. It is a great tool to add to your workflow and we highly recommend using it.