public class MyActionFilterAttribute :ActionFilterAttribute
{
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
filterContext.HttpContext.Response.Write("OnActionExecuted is Executed!<br/>");
}
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
filterContext.HttpContext.Response.Write("OnActionExecuting is Executed!<br/>");
}
public override void OnResultExecuted(ResultExecutedContext filterContext)
{
filterContext.HttpContext.Response.Write("OnResultExecuted is Executed!<br/> ");
}
public override void OnResultExecuting(ResultExecutingContext filterContext)
{
filterContext.HttpContext.Response.Write("OnResultExecuted is Executed!<br/> ");
}
}
public class HomeController : Controller
{
//
// GET: /Home/
[MyActionFilterAttribute(Order = 3)]
public string Index()
{
return "I returned an string is Hello Nikain<br/>";
}
}
{
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
filterContext.HttpContext.Response.Write("OnActionExecuted is Executed!<br/>");
}
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
filterContext.HttpContext.Response.Write("OnActionExecuting is Executed!<br/>");
}
public override void OnResultExecuted(ResultExecutedContext filterContext)
{
filterContext.HttpContext.Response.Write("OnResultExecuted is Executed!<br/> ");
}
public override void OnResultExecuting(ResultExecutingContext filterContext)
{
filterContext.HttpContext.Response.Write("OnResultExecuted is Executed!<br/> ");
}
}
public class HomeController : Controller
{
//
// GET: /Home/
[MyActionFilterAttribute(Order = 3)]
public string Index()
{
return "I returned an string is Hello Nikain<br/>";
}
}
as you can see
so it is all about the ActionFilterAttribute . once have this you can do everything you want .