Custom Shaker Bottles | Custom Water Bottle | Custom Protein Shakers
Custom action filterattribute
Click here to load reader
-
Upload
learningtech -
Category
Technology
-
view
232 -
download
0
Transcript of Custom action filterattribute
![Page 1: Custom action filterattribute](https://reader038.fdocuments.in/reader038/viewer/2022100600/5555d2d0d8b42a711f8b4afb/html5/thumbnails/1.jpg)
Custom ActionFilterAttributeBryan lin
2014/03/21
![Page 2: Custom action filterattribute](https://reader038.fdocuments.in/reader038/viewer/2022100600/5555d2d0d8b42a711f8b4afb/html5/thumbnails/2.jpg)
Agenda
Introduction of ActionFilterAttribute
Implementation of custom ActionFilterAttribute
![Page 3: Custom action filterattribute](https://reader038.fdocuments.in/reader038/viewer/2022100600/5555d2d0d8b42a711f8b4afb/html5/thumbnails/3.jpg)
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)
![Page 4: Custom action filterattribute](https://reader038.fdocuments.in/reader038/viewer/2022100600/5555d2d0d8b42a711f8b4afb/html5/thumbnails/4.jpg)
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);
![Page 5: Custom action filterattribute](https://reader038.fdocuments.in/reader038/viewer/2022100600/5555d2d0d8b42a711f8b4afb/html5/thumbnails/5.jpg)
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);
![Page 6: Custom action filterattribute](https://reader038.fdocuments.in/reader038/viewer/2022100600/5555d2d0d8b42a711f8b4afb/html5/thumbnails/6.jpg)
Implementation of custom ActionFilterAttribute
Step 1: Inherit the ActionFilterAttribute
![Page 7: Custom action filterattribute](https://reader038.fdocuments.in/reader038/viewer/2022100600/5555d2d0d8b42a711f8b4afb/html5/thumbnails/7.jpg)
Implementation of custom ActionFilterAttribute
Step 2: Override the method that you want to add your logics on the timing
![Page 8: Custom action filterattribute](https://reader038.fdocuments.in/reader038/viewer/2022100600/5555d2d0d8b42a711f8b4afb/html5/thumbnails/8.jpg)
Implementation of custom ActionFilterAttribute
Step 3: Modify the FilterConfig in App_Start folder and add your custom ActionFilterAttribute here, that’s all.
![Page 9: Custom action filterattribute](https://reader038.fdocuments.in/reader038/viewer/2022100600/5555d2d0d8b42a711f8b4afb/html5/thumbnails/9.jpg)
FAQ