Your SlideShare is downloading. ×
Custom action filterattribute
Custom action filterattribute
Custom action filterattribute
Custom action filterattribute
Custom action filterattribute
Custom action filterattribute
Custom action filterattribute
Custom action filterattribute
Custom action filterattribute
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Custom action filterattribute

236

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
236
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Custom ActionFilterAttribute Bryan lin 2014/03/21
  • 2. Agenda  Introduction of ActionFilterAttribute  Implementation of custom ActionFilterAttribute
  • 3. 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)
  • 4. 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);
  • 5. 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);
  • 6. Implementation of custom ActionFilterAttribute  Step 1: Inherit the ActionFilterAttribute
  • 7. Implementation of custom ActionFilterAttribute  Step 2: Override the method that you want to add your logics on the timing
  • 8. Implementation of custom ActionFilterAttribute  Step 3: Modify the FilterConfig in App_Start folder and add your custom ActionFilterAttribute here, that’s all.
  • 9. FAQ

×