HandleExceptionAttribute¶
Global MVC exception filter that logs unhandled action exceptions with full request diagnostic context and redirects non-AJAX requests to the shared error page, while never itself throwing regardless of logging outcome.
Purpose¶
- Global MVC exception filter that logs unhandled action exceptions with full request diagnostic context and redirects non-AJAX requests to the shared error page, while never itself throwing regardless of logging outcome.
- Depends on a property-injected
ILogServicesupplied by Autofac's MVC filter provider; when that service or the filter context is missing, the filter silently does nothing.
Context¶
- Namespace:
SAIF.Web.Mvc - Assembly/package:
SAIF.Framework.Web.Mvc (source-shipping NuGet package) - Kind: class (MVC exception filter)
Public members¶
| Member | Signature | Purpose |
|---|---|---|
| LogService | public ILogService LogService { get; set; } |
Property-injected logging service used to record the exception and its request context. |
| OnException(ExceptionContext) | public override void OnException(ExceptionContext filterContext) |
Builds diagnostic state, logs the exception, and redirects non-AJAX requests to Constants.ErrorUrl; see the "Handle and log an unhandled action exception" operation. |
Behavioral notes¶
- Never sets
filterContext.ExceptionHandled, so MVC's default error handling still runs afterwards.* - Swallows any exception raised while logging so error handling can never itself fail.
Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.
Sources¶
src/Web.Mvc/ActionFilters/HandleExceptionAttribute.cs