ASP.NET MVC应用程序中的跟踪错误

时间:2015-11-08 19:41:06

标签: asp.net-mvc-4 visual-studio-2012 windows-10

我在WIN 10上使用VS 2012创建了我的第一个MVC应用程序。我在Web.config文件的System.Web部分添加了这一行:

<trace enabled="true" pageOutput="True" />

我的machine.config文件包含以下行:

<section name="trace" type="System.Web.Configuration.TraceSection, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

和这一行:

<section name="deployment" type="System.Web.Configuration.DeploymentSection, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" allowDefinition="MachineOnly"/>

当我运行我的应用程序并输入此URL:http://localhost/MvcDemo/Trace.axd时,出现以下错误: enter image description here

我该如何解决?

1 个答案:

答案 0 :(得分:0)

根据此博文:http://knucklebones.blogspot.com/2010/11/enable-tracing-in-aspnet-mvc.html

您需要为MVC添加一些额外的web.config管道:

<system.diagnostics>
  <trace>
      <listeners>
          <add name="WebPageTraceListener"
               type="System.Web.WebPageTraceListener, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
      </listeners>
  </trace>
</system.diagnostics>