1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingsystem.web;5 usingSYSTEM.WEB.MVC;6 7 namespaceLizhugz. Areas.lizhuAdmin.Models8 {9 Public classFilterattribute:actionfilterattributeTen { One /*Filter A * Experience AOP programming Ideas - Result: View - Ation: Method the called with [FilterAttribute] - before the controller: all methods under this controller are verified - Before method: This method uses this validation - */ + Public stringMessage {Get;Set; } - + //executes after the action executes A Public Override voidonactionexecuted (actionexecutedcontext filtercontext) at { - - Base. OnActionExecuted (Filtercontext); - } - - //execute before Action executes in Public Override voidonactionexecuting (actionexecutingcontext filtercontext) - { to if(httpcontext.current.session["userId"]==NULL) + { - theHttpContext.Current.Response.Redirect ("/lizhuadmin/ademinprodata/login"); * } $ ElsePanax Notoginseng { -HttpContext.Current.Response.Redirect ("/lizhuadmin/ademinprodata/index"); the } + A the Base. OnActionExecuting (filtercontext); + - $ } $ - //executes after result is executed - Public Override voidonresultexecuted (resultexecutedcontext filtercontext) the { - Base. Onresultexecuted (filtercontext);Wuyi } the - //before result is executed Wu Public Override voidonresultexecuting (resultexecutingcontext filtercontext) - { About Base. Onresultexecuting (Filtercontext); $ } - } - - A +}
View Code
May 12, 2016 my first podcast