Wednesday, 15 February 2012

Page generation time - ASP.Net MVC -


I see how long it will take for the page generated by the server. I know that I can use the trace to track it, but I need a way to display this per page

its ASP.Net MVC 2

Yes Yes Daryn suggestion is the standard way to do this in an ASP.NET application, I will just add that if any non-HTML If the interactions do not interfere, edit: Edit: Completed implementation added A: Public class PerformanceMonitorModule: IHttpModule {Public Zero Init (HttpApplication Reference) {context.PreRequestHandlerExecute + = Representative (Object Sender, EventArgs E) {// Set Page Timer Star HttpContext requestContext = ( (HttpApplication) sender) .Context; Stopwatch timer = new stopwatch (); RequestContext.Items ["Timer"] = Timer; Timer.start (); }; Context.PostRequestHandlerExecute + = Representative (Object Sender, EventArgs E) {HttpContext HTTPContext = ((HttpApplication) Sender) .Context; HttpResponse response = httpContext.Response; Stopwatch timer = (stopwatch) httpContext.Items ["Timer"]; Timer.Stop (); // Do not interfere in non-HTML responses (feedback.contact type == "text / html") {double second = (double) timer. Appletics / Stopwatch Frequency; String result_time = string.format ("{0: F4} seconds", seconds); RenderQueriesToResponse (response, result_time); }}; } Zero RenderQueriesToResponse (HttpResponse response, string result_time) {response.Write ("div style = \" margin: 5px; background color: # FFFF00 \ "); response. Type (string format (" & lt; b & gt; ;); Response.Write ("& lt; / div & gt;");} Public Zero Extraction () {/ * Not Required}} P> You can also add some style to it ...

And remember to register your module in the webcontent section within the http module:

  and no Steven Sanderson - Chapter 15 - Demonstration of Pro ASP.NET MVC Framework for a complete reference in this regard - Addition = "Name" type = "Namespace, dll" />  

, Monitoring page generation time.

Edit: (Comment @ Pino) ​​Here is an example of my project:


No comments:

Post a Comment