Last active
December 1, 2018 21:23
-
-
Save nlivaic/d5641ce236a1a66cec927bbd44a5198e to your computer and use it in GitHub Desktop.
Custom Filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HomeController : Controller | |
{ | |
[Log] | |
public ActionResult Index() | |
{ | |
var controller = RouteData.Values["controller"]; | |
var action = RouteData.Values["action"]; | |
var id = RouteData.Values["id"]; | |
var message = $"{controller}::{action} {id}"; | |
ViewBag.Message = message; | |
return View(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LogAttribute : ActionFilterAttribute | |
{ | |
public override void OnActionExecuting(ActionExecutingContext filterContext) | |
{ | |
base.OnActionExecuting(filterContext); | |
} | |
public override void OnActionExecuted(ActionExecutedContext filterContext) | |
{ | |
base.OnActionExecuted(filterContext); | |
} | |
public override void OnResultExecuting(ResultExecutingContext filterContext) | |
{ | |
base.OnResultExecuting(filterContext); | |
} | |
public override void OnResultExecuted(ResultExecutedContext filterContext) | |
{ | |
base.OnResultExecuted(filterContext); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment