Get the code for the page execution time

xiaoxiao2021-03-05  25

Get the code of the page execution time in the global.asax.cs file

protected void Application_BeginRequest (Object sender, EventArgs e) {Application [ "StartTime"] = System.DateTime.Now;} protected void Application_EndRequest (Object sender, EventArgs e) {System.DateTime startTime = (System.DateTime) Application [ "StartTime "]; System.datetime endtime = system.datetime.now; system.timespan ts = endtime - starttime; response.write (" page execution time: ts.milliseconds "mill");}

protected

Void

Application_BeginRequest (Object Sender, Eventargs E)

{Application ["StartTime"] = system.datetime.now;}

protected

Void

Application_ENDREQUEST (Object Sender, Eventargs E)

{System.DateTime startTime = (System.DateTime) Application [ "StartTime"]; System.DateTime endTime = System.DateTime.Now; System.TimeSpan ts = endTime - startTime; Response.Write ( "Execution Time:" ts .Milliseconds "milliseconds");}

转载请注明原文地址:https://www.9cbs.com/read-34331.html

New Post(0)