Modify middleware response

前端 未结 4 1915
粉色の甜心
粉色の甜心 2020-12-06 00:30

My requirement: write a middleware that filters all \"bad words\" out of a response that comes from another subsequent middleware (e.g. Mvc).

The problem: streaming

4条回答
  •  爱一瞬间的悲伤
    2020-12-06 01:33

    A "real" production scenario may be found here: tethys logging middeware

    If you follow the logic presented in the link, do not forget to addhttpContext.Request.EnableRewind() prior calling _next(httpContext) (extension method of Microsoft.AspNetCore.Http.Internal namespace).

提交回复
热议问题