Partager via


Controller.OnResultExecuted Method

Called after the action result that is returned by an action method is executed.

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

Syntax

'Declaration
Protected Overridable Sub OnResultExecuted ( _
    filterContext As ResultExecutedContext _
)
protected virtual void OnResultExecuted(
    ResultExecutedContext filterContext
)
protected:
virtual void OnResultExecuted(
    ResultExecutedContext^ 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. This method runs after the response is written.

Examples

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

protected override void OnResultExecuted(ResultExecutedContext ctx) {
    base.OnResultExecuted(ctx);
    string sDbg = ctx.Controller.TempData["DebugTrc"] as string;
    System.Diagnostics.Debug.WriteLine("OnResultExecuted " +
    sDbg);
}
Protected Overloads Overrides Sub OnResultExecuted(ByVal ctx As ResultExecutedContext) 
    MyBase.OnResultExecuted(ctx) 
    Dim sDbg As String = TryCast(ctx.Controller.TempData("DebugTrc"), String) 
    System.Diagnostics.Debug.WriteLine("OnResultExecuted " & sDbg) 
End Sub 

See Also

Reference

Controller Class

System.Web.Mvc Namespace