22 Creating custom MVC and Razor Page filters

This chapter covers

  • Creating custom filters to refactor complex action methods
  • Using authorization filters to protect your action methods and Razor Pages
  • Short-circuiting the filter pipeline to bypass action and page handler execution
  • Injecting dependencies into filters

In chapter 21 I introduced the Model-View-Controller (MVC) and Razor Pages filter pipeline and showed where it fits into the life cycle of a request. You learned how to apply filters to your action method, controllers, and Razor Pages, and the effect of scope on the filter execution order.

In this chapter you’ll take that knowledge and apply it to a concrete example. You’ll learn to create custom filters that you can use in your ...

Get ASP.NET Core in Action, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.