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