开发者

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 the Web.config:

<trace enabled="true" 
       requestLimit="10"
       pageOutput="true"
       traceMode="SortByTime" 
       localOnly="true" 
       writeToDiagnosticsTrace="true"
开发者_C百科       />

A standard trace listener is also configured in the 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 from the controller, but when I add a Trace in the View (.aspx) nothing ever shows:

<% 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 something else that is needed to enable Tracing from a View?

Thanks


I believe this was answered by this question. Here was just a bit of the answer provided...

When you called Trace.Write() in Web Forms, you were interacting with the Trace- Context class. This exists on your ViewPage in ASP.NET MVC, but this isn’t where you would want to write tracing statements. By the time you’ve passed the baton over to the view, there’s no logic there that you’d need to trace. Instead, you’d like to trace the logic embedded in your controllers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜