Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I generate a complete trace.axd in ASP.NET MVC?

On my application, after enabling ASP.NET Tracing in an ASP.NET MVC application, the time calculation statistics were off by a factor of 5000.

I have a page that is taking between 7 and 9 seconds to load. This is corroborated by both Firebug and the "time-taken" field in the IIS log files. (This is just the page returning to the client, not any layout, DOM, or script execution.)

However, when I turn application-wide tracing on (via web.config) and view the trace output, the time taken from "Begin PreInit" to "End Render" is less than 0.001 seconds.

I assume this is because Trace.axd was built with WebForms in mind, and MVC bypasses the traditional page lifecycle.

Yet even if I add custom traces at the start and end of OnActionExecuting/OnActionExecuted, the time is still less than 0.1 seconds.

Does anyone know where in ASP.NET MVC I will need to hook in order to have the trace.axd output report accurate execution times?

like image 591
Portman Avatar asked Jul 17 '09 20:07

Portman


People also ask

How do I display trace data on a website?

Trace Configuration Attributes The default is false. You can override this setting for individual pages by setting the Trace attribute in the @ Page directive of a page to true or false. true to display trace both in pages and in the trace viewer (Trace. axd); otherwise, false.

What is trace Axd?

The Trace. axd application keeps a very detailed log of all requests made to an application over a period of time. This information includes remote client IP's, session IDs, all request and response cookies, physical paths, source code information, and potentially even usernames and passwords.

Which file gets added when tracing is enabled in the application?

When we enable application level tracing, trace information is gathered and processed for each page in that application. We can enable application level tracing by using the trace element in the Web. config file. By default, application level tracing can be viewed only on the local Web server computer.


1 Answers

It could be that the time for the action method itself is not the big part of the execution. Try checking the time between OnResultExecuting/OnResultExecuted. This is basically the time to actually render the page in HTML whereas OnActionExecuting/OnActionExecuted is (basically) the time to set up the data for the view.

Note that if you are using LINQ, the data queries themselves may be deferred until the page is rendered (the model enumerated). That is, the slowness may not be due to page complexity but data access even when the time is taken in executing the result.

like image 156
tvanfosson Avatar answered Nov 08 '22 05:11

tvanfosson