从控制器获取跟踪消息到失败的请求跟踪

从控制器获取跟踪消息到失败的请求跟踪

本文介绍了从控制器获取跟踪消息到失败的请求跟踪中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

在ASP.NET MVC预览5上,我们无法使来自全局或控制器的任何跟踪消息显示在页面(视图)或失败的请求跟踪(FREB)中.

On ASP.NET MVC Preview 5, we're having trouble getting any trace messages from Global or Controllers to appear in either a page (View) or Failed Request Tracing (FREB).

这些调用均不能在Controller Action中工作:

Neither of these calls work in a Controller Action:

HttpContext.Trace.Write("hello");
System.Diagnostics.Trace.WriteLine("world");

Page的后台代码中的trace语句没有问题;这些消息正确显示.

There are no issues with trace statements in a Page's code-behind; those messages appear correctly.

推荐答案

这些调用甚至在创建页面(ViewPage)之前发生,因此您需要在Web.config和页面中启用跟踪.

Those calls happen before the Page (ViewPage) is even created so you need to enable tracing in Web.config as well as in the page.

在Web.config中,直接在节点内添加:

In Web.config, directly within the node add:

<trace enabled="true" />

您有两个选项可以查看跟踪.您可以在@Page声明中的视图中启用它.

You have two options to view the trace. You can enable it in your view within the @Page declaration.

<%@ Page ... Trace="true" %>

或者您可以导航到/trace.axd

Or you can navigate to /trace.axd

请注意,我们确实有一个错误,但是我不记得它何时修复.我是在Beta版中尝试过的,而不是在Preview 5中试用过.

Note that we did have a bug with this, but I don't remember when it was fixed. I tried this with the Beta, not with Preview 5.

这篇关于从控制器获取跟踪消息到失败的请求跟踪中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 02:22