public class CustomActionFilter : ActionFilterAttribute, IActionFilter
{
void IActionFilter.OnActionExecuting(ActionExecutingContext filterContext)
{
Stopwatch tmr = new Stopwatch();
tmr.Start();
filterContext.HttpContext.Items["tmr"] = tmr;
Debug.WriteLine(JsonConvert.SerializeObject(filterContext.ActionParameters));
}
void IActionFilter.OnActionExecuted(ActionExecutedContext filterContext)
{
Stopwatch tmr = (Stopwatch)filterContext.HttpContext.Items["tmr"];
Debug.WriteLine(tmr.ElapsedMilliseconds);
}
}
[CustomActionFilter]
public ActionResult Index(string p1, string p2)
{
return Content(DateTime.Now.ToString());
}