Using ASP.NET Core DI to inject objects into ActionFilterAttribute
Problem
Let’s assume you want to validate something before a request hits your ASP.NET Core controller’s action method. One of the possible solutions is to create an ActionFilterAttribute
and use its OnActionExecutionAsync
(in case you like to do it asynchronously) to do the checking. Now if you are depending on something like configuration or even another instance of a class it is going to be tricky.
Oct 04, 2017
2 min