ASP.NET MVC 3 Custom Action FiltersVersion: 1.1.0 DescriptionIn ASP.NET MVC 3 Global, Dynamic Filters Hands-on Lab, you have been adding filters to MVC processing. In this Hands-on Lab, you will use custom filters to log your site activity. To achieve that, in the proposed exercise you will create a custom filter attribute that will work with any specified controller. That filter will catch controller's requests, and save them into a database table. Through a log view you will be able to see the list of visits that each filtered controller had. Overview
Note:
This Hands-on Lab assumes you have basic knowledge of ASP.NET MVC. If you have not used ASP.NET MVC before, we recommend you to go over ASP.NET MVC Fundamentals Hand-on Lab.
ASP.NET MVC provides Action Filters for performing logic either before an action method is called or after its run. Action Filters are custom attributes that provide a declarative means to add pre-action and post-action behavior to controller action methods. In this Hands-on Lab you will create a custom action filter attribute into MVC Music Store solution to catch controller’s requests and log site actvity into a database table. You will be able to add your logging filter by injection to any controller or action. Finally, you will see the log view that shows a visit list. ObjectivesIn this Hands-On Lab, you will learn how to:
System RequirementsYou must have the following items to complete this lab:
SetupInstalling Code SnippetsFor convenience, much of the code you will be managing along this lab is available as Visual Studio code snippets. To install the code snippets run .\Source\Assets\CodeSnippets.vsi file. ExercisesThis Hands-On Lab is comprised by the following exercises:
Estimated time to complete this lab: 20 minutes. Note: Each exercise is accompanied by an End folder containing the resulting solution you should obtain after completing the exercises. You can use this solution as a guide if you need additional help working through the exercises. Next Step |