asp.net core mvc异常处理
过滤器处理异常
public class GlobalExceptionFilter : IExceptionFilter
{
private ILogger
public GlobalExceptionFilter(ILogger
{
_logger = logger;
}
public void OnException(ExceptionContext context)
{
var controller = context.ActionDescriptor;
context.ExceptionHandled = true;
var httpCpde = context.Exception;
_logger.LogError(new EventId(),context.Exception,null);
context.Result = new RedirectResult("/home/Page500");
}
}