Just curious, they sound similar. What are the differences between ExecuteCore() vs OnActionExecuting(ActionExecutingContext filterContext)?
In what situations would one be more useful over the other?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Actually, they’re just different points in MVC execution pipeline.
ExecuteCore is called by
MvcHandler after controller itself
is instantiated. By this moment MVC
doesn’t even know about how
controller will invoke its action.
You can override standard
Controller’s ExecuteCore to tweak
its overall execution process a
little bit.
OnActionExecuting is a completely
different story. It is called during
action filters invocation by
ControllerActionInvoker. By that
point MVC already knows that action
exists, invokes it, obtains all
filters (usually defined as
attributes) and executes it in a
given moment of overall execution
pipeline (OnActionExecuting,
OnActionExecuted, OnResultExecuting
and so on).
It depends on what exactly you want to achieve when deciding what extension point to use.
Controller to tweak its common
behavior (not really often the case
in normal app).
perform some additional tasks that
seem orthogonal to what acion itself
is supposed to do (often this is some
AOP-like logic or relates to database session/transaction management).