Measure request/response times of an Asp.Net MVC applicationRamesh S10yAsked Feb 4, 2016, 4:25 AM2.9k.NETHow to Measure request/response times of an Asp.Net MVC application?
Francis Susaimichael10y agoPosted Feb 4, 2016, 6:03 AMAccepted answer You can consider to use "Action Filters" in that case. https://msdn.microsoft.com/en-in/library/dd410209(v=vs.100).aspx 0
Ramesh S10y agoPosted Feb 4, 2016, 6:10 AMusing System;using System.Collections.Generic;using System.Diagnostics;using System.Linq;using System.Web;using System.Web.Mvc;namespace SW{ public class StopwatchAttribute : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { var stopwatch = new Stopwatch(); filterContext.HttpContext.Items["Stopwatch"] = stopwatch; stopwatch.Start(); } public override void OnResultExecuted(ResultExecutedContext filterContext) { var stopwatch = (Stopwatch)filterContext.HttpContext.Items["Stopwatch"]; stopwatch.Stop(); var httpContext = filterContext.HttpContext; var response = httpContext.Response; response.AddHeader("X-Runtime", stopwatch.Elapsed.TotalMilliseconds.ToString()); } }}0
Suresh M10y agoPosted Feb 4, 2016, 5:51 AMStart the stop watch before your request and stop the stopwatch .then you can able to get the time taken0
Ramesh S10y agoPosted Feb 4, 2016, 4:57 AMsend one request to some action that action how match time take full application one code0
Suresh M10y agoPosted Feb 4, 2016, 4:46 AMuse stopwatch class for example http://www.c-sharpcorner.com/UploadFile/2b876a/create-stop-watch-demo-in-windows-10-uwp135/ 0
Francis SusaimichaelPosted Feb 4, 2016, 6:03 AM
You can consider to use "Action Filters" in that case.
https://msdn.microsoft.com/en-in/library/dd410209(v=vs.100).aspx
Francis SusaimichaelPosted Feb 4, 2016, 7:54 AM
Ramesh SPosted Feb 4, 2016, 6:21 AM
Ramesh SPosted Feb 4, 2016, 6:10 AM
Ramesh SPosted Feb 4, 2016, 5:55 AM
Suresh MPosted Feb 4, 2016, 5:51 AM
Ramesh SPosted Feb 4, 2016, 4:57 AM
Suresh MPosted Feb 4, 2016, 4:46 AM