Getting Trace messages into Failed Request Tracing from Controllers

雨燕双飞 提交于 2019-12-12 18:18:46

问题


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).

Neither of these calls work in a Controller Action:

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

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


回答1:


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.

In Web.config, directly within the node add:

<trace enabled="true" />

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

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

Or you can navigate to /trace.axd

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.



来源:https://stackoverflow.com/questions/442258/getting-trace-messages-into-failed-request-tracing-from-controllers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!