ASP.NET Core middleware vs filters

There is a video about this on channel 9: ASP.NET Monsters #91: Middleware vs. Filters. To summarize the video:

The execution of request starts and we have a middleware, and another middleware, think of it like the “Russian dolls inside of dolls” and eventually the routing middleware kicks in and then request goes into the MVC pipline.
enter image description here
So if you don’t require the context of MVC (let’s say you’re concerned about flow and execution, like responding to headers some pre-routing mechanism, etc.) then use middlewares.
But if you require the context of MVC and you want to operate against actions then use filters.

Leave a Comment