Does IExceptionLogger deprecate the need for ExceptionFilterAttribute in Web API 2?

后端 未结 2 1208
我寻月下人不归
我寻月下人不归 2021-02-19 10:44

Following the discussion from the official documentation on implementing an IExceptionLogger (http://www.asp.net/web-api/overview/testing-and-debugging/web-api-glob

2条回答
  •  鱼传尺愫
    2021-02-19 11:32

    ExceptionFilterAttribute is not deprecated.

    Why not?
    An IExceptionLogger can't set a response. You have to use an ExceptionFilterAttribute or an IExceptionHandler to handle exceptions with a custom response message.
    As the name suggest it can only log the exception.

    The ExceptionLoggerContext.ExceptionContext has an Response porperty. You can set the property to a HttpRespnseMessage but it has no effect on the response.

    Maybe IExceptionHandler deprecates ExceptionFilterAttribute. But i don't know.

提交回复
热议问题