Question

I am handing exception in Controller, and other layers that I have manually added like DataAccess.

I have also placed exception handling in Views.

Is it necessary to do so, or can I remove the exception handling code from view?

Was it helpful?

Solution

This is not necessary, ASP.NET haves exception handling by itself. You only have to throw a exception. The view will catch it automatically when running on 'release' mode

Just add the 'FilterConfig' in your App_start

public class FilterConfig
{
    /// <summary>
    /// The register global filters.
    /// </summary>
    /// <param name="filters">
    /// The filters.
    /// </param>
    public static void RegisterGlobalFilters(GlobalFilterCollection filters)
    {
        filters.Add(new HandleErrorAttribute());
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top