Custom action filterattribute
Upcoming SlideShare
Loading in...5
×
 

Custom action filterattribute

on

  • 212 views

 

Statistics

Views

Total Views
212
Views on SlideShare
211
Embed Views
1

Actions

Likes
0
Downloads
2
Comments
0

1 Embed 1

http://www.slideee.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Custom action filterattribute Custom action filterattribute Presentation Transcript

  • Custom ActionFilterAttribute Bryan lin 2014/03/21
  • Agenda  Introduction of ActionFilterAttribute  Implementation of custom ActionFilterAttribute
  • Introduction of ActionFilterAttribute  System.Web.Mvc.ActionFilterAttribute has the ability for inserting some logics before/after action executing or result executing(such as render html)
  • Introduction of ActionFilterAttribute  System.Web.Mvc.ActionFilterAttribute has 4 methods:  public virtual void OnActionExecuted(ActionExecutedContext filterContext);  public virtual void OnActionExecuting(ActionExecutingContext filterContext);  public virtual void OnResultExecuted(ResultExecutedContext filterContext);  public virtual void OnResultExecuting(ResultExecutingContext filterContext);
  • Introduction of ActionFilterAttribute  Do something before action executing, we can override the method  public override void OnActionExecuted(ActionExecutedContext filterContext);  Do something after action executing, we can override the method  public override void OnActionExecuting(ActionExecutingContext filterContext);  Do something before result executing, we can override the method  public override void OnResultExecuted(ResultExecutedContext filterContext);  Do something after result executing, we can override the method  public virtual void OnResultExecuting(ResultExecutingContext filterContext);
  • Implementation of custom ActionFilterAttribute  Step 1: Inherit the ActionFilterAttribute
  • Implementation of custom ActionFilterAttribute  Step 2: Override the method that you want to add your logics on the timing
  • Implementation of custom ActionFilterAttribute  Step 3: Modify the FilterConfig in App_Start folder and add your custom ActionFilterAttribute here, that’s all.
  • FAQ