Action filter

810 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
810
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • public class ShowMessageAttribute : ActionFilterAttribute{ public string Message { get; set; } public override void OnActionExecuting(ActionExecutingContextfilterContext) { filterContext.HttpContext.Response.Write("[BeforeAction " + Message + "]"); } public override void OnActionExecuted(ActionExecutedContextfilterContext) { filterContext.HttpContext.Response.Write("[AfterAction " + Message + "]"); } public override void OnResultExecuting(ResultExecutingContextfilterContext) { filterContext.HttpContext.Response.Write("[BeforeResult " + Message + "]"); } public override void OnResultExecuted(ResultExecutedContextfilterContext) { filterContext.HttpContext.Response.Write("[AfterResult " + Message + "]"); } }
  • Action filter

    1. 1. MVC – Action Filter Jason
    2. 2. Types of Action Filter
    3. 3. Authorization Filter
    4. 4. Action Filter
    5. 5. Result Filter
    6. 6. Action Filter  You can apply filters either to individual action methods or to all the action methods on a given controller
    7. 7. Action Filter Method Method When Called OnActionExecuting() Before the action method runs OnActionExecuted() After the action method runs OnResultExecuting() Before the ActionResult isexecuted OnResultExecuted() After the ActionResult is executed
    8. 8. Action Filter
    9. 9. Exception Filter
    10. 10. Reference  MSDN – Action Filter ◦ http://msdn.microsoft.com/en-us/library/dd381609(v=vs.100).aspx  Pro ASP.NET MVC 2 Framework, Second Edition ◦ ltfs2rdeBookASP.NETMVC2

    ×