O'Reilly logo

Applied ASP.NET 4 in Context by Adam Freeman

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

Dealing with Exceptions

We can deal with exceptions by using the HandleError attribute. This is an example of a filter, which allows us to deal with cross-cutting concerns. As I explained in Chapter 22, cross-cutting concerns are features or functions that are used through an application but that don't fit neatly into our MVC pattern. We'll see another example of filters when we look at authorization in Chapter 34.

Before we can use the HandleError attribute, we have to make an addition to the Web.config file, as shown in Listing 28-24.

Listing 28-24. Enabling custom errors in Web.config

<configuration>   …   <system.web>     <customErrors mode="On"/> </system.web> … </configuration>

We have to define the customErrors element with a value ...

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