Q: How do I calculate the total time it takes to render an MVC page and display the time on the master page.
In Asp.net Web Form I created a Base page class like so:
I would probably override the OnActionExecuting and OnActionExecuted methods on the Controller class.
public class BaseController : Controller {
// Called before the action is executed
public override void OnActionExecuting(ActionExecutingContext ctx) {
base.OnActionExecuting(ctx);
// Start timing
}
// Called after the action is executed
public override void OnActionExecuted(ActionExecutedContext ctx) {
base.OnActionExecuted(ctx);
// Stop timing
}
}