Page Render Time in ASP.MVC in trace

Posted by Pankaj on Stack Overflow See other posts from Stack Overflow or by Pankaj
Published on 2010-05-24T09:46:35Z Indexed on 2010/05/24 9:51 UTC
Read the original article Hit count: 267

Filed under:
|

Hello Everyone

I want to check render time of each page in asp.net mvc application.

i am using asp.net tracing. i have override the OnActionExecuting and OnActionExecuted methods on the BaseController class.

protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            string controler = filterContext.RouteData.Values["controller"].ToString();
            string action = filterContext.RouteData.Values["action"].ToString();
            StartTime =System.DateTime.Now;

            System.Diagnostics.Trace.Write(string.Format("Start '{0}/{1}' on: {2}", controler, action, System.DateTime.Now.UtilToISOFormat()));
        }
        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            string controler = filterContext.RouteData.Values["controller"].ToString();
            string action = filterContext.RouteData.Values["action"].ToString();
            var totalTime = System.DateTime.Now - this.StartTime;
            System.Diagnostics.Trace.Write(totalTime.ToString());
            System.Diagnostics.Trace.Write(string.Format("End '{0}/{1}' on: {2}", controler, action, System.DateTime.Now.UtilToISOFormat()));

        }

in OnActionExecuted method i get total time. how can i show this time in my http://localhost:51335/Trace.axd report?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about tracing