Why call base.OnActionExecuting(filterContext);?

Should I be always be calling the base methods after?

That will depend on the situation.

For example in authorization filters (deriving from AuthorizeAttribute) if you call the base method then all the existing authorization logic built into ASP.NET MVC will be executed. If you don’t call it, only your authorization logic will be applied.

As far as other standard action filters are concerned (deriving from ActionFilterAttribute) all the OnActionExecuting, OnActionExecuted, OnResultExecuting and OnResultExecuted are defined as virtual but their body is empty, so it doesn’t make any difference if you call or not the base method.

Leave a Comment