Exercise 3: Injecting Action Filters
In a previous Lab about Custom Action Filters you have been working with filters customization and injection. In this exercise,you will learn how to inject filters with Dependency Injection by using Unity Application Block containers. To do that, you will add to the Music Store Solution a custom action filter that will trace site activity.
Task 1 – Including the Tracking Filter in the Solution
In this task, you will include in the Music Store a custom action filter for event tracing. As filters were treated in a previous Lab “Custom Action Filters”, you will include the filter class from the Assets folder and then create a Filter Provider for Unity:
Make the class inherit from IFilterProvider Interface.
public class FilterProvider : IFilterProvider
Public Class FilterProvider
Task 2 – Registering and Enabling the Filter
Task 3 – Running the Application
In this task, you will run the application and test that the custom action filter is tracing the activity: