Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC Tracing Issues
    text
    copied!<h2>Question</h2> <p>How do I get ASP.NET MVC trace information to be consistent for in-page trace output as trace.axd? I may just be missing something obvious, please call it out if you see it.</p> <h2>Background Info for Traditional ASP.NET</h2> <p>So back in the regular ASP.NET days, you could simply add the following to your web.config:</p> <pre><code>&lt;system.diagnostics&gt; &lt;trace&gt; &lt;listeners&gt; &lt;add name="WebPageTraceListener" type="System.Web.WebPageTraceListener, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/&gt; &lt;/listeners&gt; &lt;/trace&gt; &lt;/system.diagnostics&gt; ... &lt;system.web&gt; &lt;trace enabled="true" pageOutput="true" writeToDiagnosticsTrace="true"/&gt; ... &lt;system.codedom&gt; &lt;compilers&gt; &lt;compiler language="c#;cs;csharp" extension=".cs" warningLevel="1" compilerOptions="/d:TRACE" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"&gt; </code></pre> <p>Then you could add the following in your pages:</p> <pre><code>HttpContext.Current.Trace.Write("Write Trace Here"); or System.Diagnostics.Trace.Write("Write Trace Here"); </code></pre> <p>And if you hit your page (i.e. localhost:61115/Default.aspx), you would get a nice trace table with your custom trace embedded with asp.net page events:</p> <pre><code>aspx.page Begin Load 0.00343 0.000357 test 0.00462176 0.001192 aspx.page End Load 0.00526904 0.000018 </code></pre> <p>Hitting localhost:61115/Trace.axd?id=0 would retain the same trace results as the in-page trace outputs.</p> <h2>Background Info on ASP.NET MVC</h2> <p>Unfortunately, I cannot get this to work in ASP.NET MVC 2.0 for reasons unknown to me. I use similar web.config settings as ones listed above. What is interesting is that I can only get traces to partially work. So if I hit the functionality equivalent default page (aka index action method of my homecontroller), I see all of the traditional asp.net page events such as preinit, preload, prerender, etc but no custom trace msg using either System.Diagnostics nor HttpContext.Trace.Write.</p> <p>However, if I turn to the Trace.axd?id=0 file, I'm greeted with my custom trace messages but no ASP.NET page event trace output. I must be missing something here that is causing this inconsistency in trace information I see in-page vs. trace.axd (recall that traditional asp.net outputs identical in-page vs. trace.axd outputs). I would really like to have my in-page trace information consistent with trace.axd (either by removing the traditional asp.net page events or other means). Is there something I am missing? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload