This is a mirror of official site: http://jasper-net.blogspot.com/

Creating Action Filters in ASP.NET MVC Applications

| Monday, August 9, 2010
Introduction

ASP.NET MVC Applications contains the action methods in the controllers. These actions are mapped through the routing when a user makes a browser request. In order to execute your logic before a action method is called or after an action method runs. ASP.NET MVC support this requirement through a concept called ActionFilters.

ActionFilter Uses

Authentication and Authorization can be implemented using action filters.
User actions can be logged.
For setting up the Localization feature in the application.
For Changing the Application behavior based on browser user agent.
Creating an ActionFilter in ASP.NET MVC Application

You can write a ActionFilter class by inherting from ActionFileAttribute class. You can override the method OnActionExecuting and write the logic that executes before Action Method.

To Add a ActionFilter to the ASP.NET MVC Application right click the Controllers folder in the project and select the add new item option and add the class template write the following code.

Read more: TECHBUBBLES

Posted via email from .NET Info

0 comments: