2
我不知道为什么我的异常没有在这里处理,认为我创建了正确的异常过滤器,但我可能犯了一个错误。异常过滤不工作在ASP .NET核心2.0
这里是我的筛选:
public class ExceptionAttribute : ExceptionFilterAttribute, IAsyncExceptionFilter, IExceptionFilter
{
public override void OnException(ExceptionContext context)
{
context.Result = new JsonResult(new
{
context.Exception.Message,
context.Exception.StackTrace,
});
context.ExceptionHandled = true;
}
}
我的控制器动作:
[HttpDelete("{id}")]
[Exception]
public ActionResult Delete(Guid id)
{
this.eventRepository.DeleteEvent(id);
return this.StatusCode(StatusCodes.Status202Accepted);
}
我的异常,在仓库中抛出,但应该泡在这里?它不会最终在任何地方处理,只是抛出。感谢您的任何见解。