How can we run a method before running each Action in MVC3?
I know we can use the following method for OnActionExecuting :
public class ValidateUserSessionFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
...
}
}
But how can we run a method before ActionExecuting ?
You’re looking for Controller.ExecuteCore().
This function is called before each action calls. You can override it in a controller or a base controller. Example that sets culture base on cookies from Nadeem Afana: