Does ASP.NET Tracing work in MVC2 Views?

I have a VS 2010 MVC2.NET 4.0 web application. ASP.NET tracing is enabled both in the page directive (Trace = "true) and in Web.config:

<trace enabled="true" requestLimit="10" pageOutput="true" traceMode="SortByTime" localOnly="true" writeToDiagnosticsTrace="true" /> 

A standard listening tracer is also configured in Web.config:

 <trace autoflush="true" indentsize="4"> <listeners> <add name="WebPageTrace" type="System.Web.WebPageTraceListener, System.Web, Version=4.0.30319.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <add name="TextWriterTrace" type="System.Diagnostics.TextWriterTraceListener" initializeData="textListener.log" /> </listeners> </trace> 

Tracing works fine with the controller, but when I add Trace to the View (.aspx), nothing is displayed:

 <% System.Diagnostics.Trace.WriteLine("Message System.Diagnostics.Trace from View"); %> <% Page.Trace.Write("Message Page.Trace from View"); %> 

Is this supposed to work? Is there anything else that is needed to enable tracing from the view?

thanks

+6
asp.net-mvc trace
source share
1 answer

I believe this question answered this question. Here is just a little answer ...

When you called Trace.Write () on Web Forms, you interacted with Trace, the context class. This exists on your ViewPage in ASP.NET MVC, but it isnt where you would like to write tracking statements. By the time you passed the baton in appearance, there is no logic there that you need to trace. Instead, you need to track the logic built into your controllers

+1
source share

All Articles