Back to top

1 post tagged with "actionfilterattribute"

Using ASP.NET Core DI to inject objects into ActionFilterAttribute


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.

PublishedOct 04, 2017
Time to read3 min
actionfilterattributeaspnetcoreaspnetmvcRead more