Controller.OnResultExecuting Method

Called before 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 OnResultExecuting ( _
    filterContext As ResultExecutingContext _
)
protected virtual void OnResultExecuting(
    ResultExecutingContext filterContext
)
protected:
virtual void OnResultExecuting(
    ResultExecutingContext^ 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 about the current clock ticks before the action result is returned to the response.

protected override void OnResultExecuting(ResultExecutingContext ctx) {
    base.OnResultExecuting(ctx);
    ctx.HttpContext.Trace.Write("Log: OnResultExecuting",
       "Before Result " +
         ctx.HttpContext.Timestamp.Ticks.ToString());
}
Protected Overloads Overrides Sub OnResultExecuting(ByVal ctx As ResultExecutingContext) 
    MyBase.OnResultExecuting(ctx) 
    ctx.HttpContext.Trace.Write("Log: OnResultExecuting", "Before Result " & ctx.HttpContext.Timestamp.Ticks.ToString()) 
End Sub

See Also

Reference

Controller Class

System.Web.Mvc Namespace