标签:control filter message content des mes new ext base
public class ExceptionFilter : IExceptionFilter
{
public void OnException(ExceptionContext context)
{
if (context.ExceptionHandled == false)
{
context.Result = new ContentResult
{
Content = context.Exception.Message,//这里是把异常抛出。也可以不抛出。
StatusCode = StatusCodes.Status500InternalServerError,
ContentType = "text/html;charset=utf-8"
};
}
context.ExceptionHandled = true;
}
}
在BaseController中
[TypeFilter(typeof(ExceptionFilter))]
标签:control filter message content des mes new ext base
原文地址:https://www.cnblogs.com/bugenniduobb/p/14131765.html