Controller.OnActionExecuted Method

Called after the action method is invoked.

Namespace:  System.Web.Mvc
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

Syntax

'Declaration
Protected Overridable Sub OnActionExecuted ( _
    filterContext As ActionExecutedContext _
)
protected virtual void OnActionExecuted(
    ActionExecutedContext filterContext
)
protected:
virtual void OnActionExecuted(
    ActionExecutedContext^ filterContext
)

Parameters

Remarks

If this method is overridden in a derived Controller class, it will be called for every action method in the class. For more flexibility, derive a class from ActionFilterAttribute and override this method in the derived ActionFilterAttribute class.

Examples

The following example shows how to write trace information for the action name before the action method runs.

protected override void OnActionExecuted(ActionExecutedContext ctx) {
    base.OnActionExecuted(ctx);
    ctx.HttpContext.Trace.Write("Log: OnActionExecuted",
        "After " +
        ctx.ActionDescriptor.ActionName);
}
Protected Overloads Overrides Sub OnActionExecuted(ByVal ctx As ActionExecutedContext) 
    MyBase.OnActionExecuted(ctx) 
    ctx.HttpContext.Trace.Write("Log: OnActionExecuted", "After " &       ctx.ActionDescriptor.ActionName) 
End Sub  

See Also

Reference

Controller Class

System.Web.Mvc Namespace