custom-error-pagesapplication-error

which one is better: CustomErrors in web.config or application_error?


I'm trapping 404 errors in my MVC website. I have the option to either do that via adding the customerrors element in web.config or application_error, but I don't know which one is better. What is the difference between the two?


Solution

  • I'd recommend you to use the application_error approach. This way you can log the 404'd request data, in a way that you can generate future reports. AFAIK, if you redirect the request using web.config settings, you lose this info.