When to use HttpMessageHandler vs ActionFilter?

前端 未结 2 1098
心在旅途
心在旅途 2020-12-23 09:40

It seems that these two have a similar purpose. It would be great to see some examples when to use one over the other, pros and cons, as well as point out what are the key d

2条回答
  •  北海茫月
    2020-12-23 09:55

    The major difference between their two is their focus. Message Handlers are applied to all HTTP requests. They perform the function of an HTTP intermediary. Filters apply only to requests that are dispatched to the particular controller/action where the filter is applied.

    You should use MessageHandlers when you want the behaviour to be applied to the vast majority of requests. Filters should be used when they are only applicable to certain resources.

    enter image description here

提交回复
热议问题