Is there an easy way to get the total page response time in ASP.Net?

it is usually said that PHP or other web frameworks that receive a total response time is easy, just start the timer at the top of the file and stop it at the end.

ASP.Net has the whole bit of the page life cycle, so I'm not sure how to do this. I would like this response time record to be executed on the main page, and the response time to be displayed in the page footer. What would be the best way to do this? Is there anything for ASP.Net? Is it possible to enable OnRender time?

+3
source share
3 answers

You can do it on Global.asax, look at the article

void Application_BeginRequest(object sender, EventArgs e)
{
HttpContext.Current.Items["renderStartTime"] = DateTime.Now;
}

void Application_EndRequest(object sender, EventArgs e)
{
DateTime start = (DateTime) HttpContext.Current.Items["renderStartTime"];
TimeSpan renderTime = DateTime.Now - start;
HttpContext.Current.Response.Write("<!-- Render Time: " + renderTime + " -->");
}
+5

  • begin_request end_request global.asax
  • Firebug , , .

:

ASP.NET

+2

Visual Studio Team System (, ), Visual Studio Profiler (http://msdn.microsoft.com/en-us/magazine/cc337887.aspx), , .

0

Source: https://habr.com/ru/post/1748259/


All Articles