How to Define Exception Filter in ASP.NET MVC ?
Exception filters implement IExceptionFilter and execute if there is an unhandled exception thrown. ASP.Net MVC provides HandleErrorAttribute class as an exception filter .
Authorize filter attribute implements the IAuthorizationFilter interface. The definition of this interface is given below :-
Code :
public interface IAuthorizationFilter
{
void OnAuthorization(AuthorizationContext filterContext);
}
Exception filters can be used for logging or displaying an error page. We may also define our custom exception filter.
MVC , .NET CORE 1.0 , Razor , CRUD , AJAX , C#