Manoj Sharma Manoj Sharma - 2 months ago 6x
ASP.NET (C#) Question

Exception Handling in ASP.NET MVC 4, 5

I am using ASP.NET MVC 4

I want to trace or handle Exception globally.

1.Which is handled by user code?

2.Which is not handled by user code?

both the type

how is it possible ?


Shows different ways of handling errors globally. Setting a global exception handling filter is the usual.

GlobalFilters.Filters.Add(new SpecialHandleErrorAttributeCreatedByYou());

You would derive a new Attribute from HandleErrorAttribute and put your logic in there, overriding the OnException method.

public override void OnException(ExceptionContext filterContext)

However this will not show you exceptions that are handled by other code. That is the point, they are handled so they do not continue to bubble up the stack. You would have to put code in each of those catch blocks to either do what you want.