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

我怕爱的太早我们不能终老 提交于 2019-12-09 10:36:03

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/1145608/how-can-i-generate-a-complete-trace-axd-in-asp-net-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!