Question 178


Exam Question

Drag and Drop
You are developing an ASP.NET MVC application. Before an action is executed, information about the action must be written to a log. After results are returned, information about the results also must be written to the log. You need to log the actions and results.

  • OnActionExecuting(ActionExecutingContext filterContext)
  • OnActionExecuted(ActionExecuted filterContext)
  • OnResultExecuting(ResultExecutingContext filterContext)
  • OnResultExecuted(RequlstExecutedContext filterContext)
  • public class LogActionFilter : ActionFilterAttribute
  • public class LogActionFilter : IActionFilter
    {
    public override void
      {
      Logger.Log("actionLog",filterContext.RouteData)
      }
      public override void
        {
        Logger.Log("resultLog",filterContextRouteData);
        }
        }

        Answer:

        • OnActionExecuted(ActionExecuted filterContext)
        • OnResultExecuted(RequlstExecutedContext filterContext)
        • public class LogActionFilter : IActionFilter
        • public class LogActionFilter : ActionFilterAttribute
        {
        public override void
        • OnActionExecuting(ActionExecutingContext filterContext)
        {
        Logger.Log("actionLog",filterContext.RouteData)
        }
        public override void
        • OnResultExecuting(ResultExecutingContext filterContext)
        {
        Logger.Log("resultLog",filterContextRouteData);
        }
        }