Code snippet to calculate the loading time of ASP page [Resolved]

Posted by Amatya under Data Structures & Algorithms on 2/12/2016 | Points: 10 | Views : 1388 | Status : [Member] | Replies : 1
Do anyone have a code snippet to calculate the loading time of ASP page or any material that can be helpful?

Feel free to share informations.
mail Id '


Posted by: Rajnilari2015 on: 2/12/2016 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50


Try this

In ASP.NET, this can be achieved using the application class which acts as an entry point for all incoming requests.

Use the below piece of code in the global.asax.cs file

protected void Application_BeginRequest(Object sender, EventArgs e) {
Context.Items.Add("StartTime", DateTime.Now);

Application_BeginRequest event is use to start the measurement of the time spent on the server-side process.

protected void Application_EndRequest(Object sender, EventArgs e)
var ts = DateTime.Now.Subtract((DateTime)Context.Items["StartTime"]);
Response.Write("<h6>Page load time " + ts + "ms</h6>");

This calculate the elapsed time on the webform's.

Hope this helps.

Thanks & Regards,
RNA Team

Amatya, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response