第二次请求后 HttpContext.Current.Trace.IsEnabled 莫名其妙地变成 false
在我的 web.config 中,启用了跟踪。在第一个请求中,页面跟踪显示。然后在第二页上,Trace.IsEnabled 变为 false。我不记得以前见过这种行为。我已经搜索了所有源代码,但找不到任何可能禁用它的对 Trace 的引用。
参考号web.config
<trace enabled="true" localOnly="false" pageOutput="true" />
这是我目前的工作,在 global.asax 中,我添加了它
protected void Session_Start(object sender, EventArgs e)
{
if(HttpContext.Current.Trace.IsEnabled) //True on 1st request
Session["TraceEnabled"] = true;
,然后将其添加到自定义基页面中的早期事件中。
if (Session["TraceEnabled"] != null)
HttpContext.Current.Trace.IsEnabled = true;
然后跟踪按预期恢复。
为什么跟踪可能会自行关闭?我宁愿解决根本问题,也不愿做一些笨拙的工作。
In my web.config, trace is enabled. On the 1st request, in page trace shows up. Then on the second page, Trace.IsEnabled becomes false. I don't recall ever seeing this behavior before. I've search the source code everything and I can't find any references to Trace that might be disabling it.
Ref. web.config
<trace enabled="true" localOnly="false" pageOutput="true" />
Here is my work around for the moment, in global.asax, I added this
protected void Session_Start(object sender, EventArgs e)
{
if(HttpContext.Current.Trace.IsEnabled) //True on 1st request
Session["TraceEnabled"] = true;
I then added this to an early event in a custom base page.
if (Session["TraceEnabled"] != null)
HttpContext.Current.Trace.IsEnabled = true;
Trace then resumes as expected.
Why might trace turn itself off? I'd rather fix the root problem than having a clunky work around.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是否尝试过增加配置文件中的
requestLimit
属性?Have tried to increase the
requestLimit
attribute on your configuration file?