gpt4 book ai didi

asp.net-mvc - ASP.NET 跟踪在 MVC2 View 中工作吗?

转载 作者:行者123 更新时间:2023-12-04 16:02:38 24 4
gpt4 key购买 nike

我有一个 VS 2010 MVC2 .NET 4.0 Web 应用程序。在 Page 指令 (Trace="true) 和 Web.config 中都启用了 ASP.NET 跟踪:

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

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>

跟踪在 Controller 中工作正常,但是当我在 View (.aspx) 中添加跟踪时,没有任何显示:
<% System.Diagnostics.Trace.WriteLine("Message System.Diagnostics.Trace from View"); %>
<% Page.Trace.Write("Message Page.Trace from View"); %>

这应该有效吗?从 View 启用跟踪还需要其他什么吗?

谢谢

最佳答案

我相信这是由 this 回答的题。这里只是提供了一些答案......

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

关于asp.net-mvc - ASP.NET 跟踪在 MVC2 View 中工作吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2738092/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com