当ASP.NET处理未处理的异常时,事件日志消息会扩展

时间:2022-01-26 03:36:18

If I throw an unhandled exception from ASP.NET, a warning is added to the eventlog (as expected).

如果我从ASP.NET中抛出未处理的异常,则会向事件日志添加警告(如预期的那样)。

But if the message in the exception contains a %, the message in the eventlog gets garbled:

但是,如果异常中的消息包含%,则事件日志中的消息会出现乱码:

If the Message was

如果消息是

Could not find foo%20bar

the eventlog will read

事件日志将会读取

Could not find foohttp://localhost/testpage.aspxbar

Other numeric values after the % will be converted to other strings.

%之后的其他数值将转换为其他字符串。

It looks like the message gets passed through a printf-statement somewhere on the way.

看起来消息在路上的某个地方通过printf语句传递。

Is this per design? Is there a way to avoid this (besides making sure that exceptions are handled)?

这是每个设计?有没有办法避免这种情况(除了确保处理异常)?

EDIT:

If I look at the XML-view under details in the eventlog, I see:

如果我在事件日志中查看详细信息下的XML视图,我会看到:

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
  <Provider Name="ASP.NET 2.0.50727.0" /> 
  <EventID Qualifiers="32768">1309</EventID> 
  <Level>3</Level> 
  <Task>3</Task> 
  <Keywords>0x80000000000000</Keywords> 
  <TimeCreated SystemTime="2009-06-26T11:10:09.000Z" /> 
  <EventRecordID>130253</EventRecordID> 
  <Channel>Application</Channel> 
  <Computer>XXX</Computer> 
  <Security /> 
</System>
<EventData>
  <Data>3005</Data> 
  <Data>An unhandled exception has occurred.</Data> 
  <Data>26-06-2009 13:10:09</Data> 
  <Data>26-06-2009 11:10:09</Data> 
  <Data>525e4e8df6ec432d9a9b9b77e9ded580</Data> 
  <Data>6</Data> 
  <Data>1</Data> 
  <Data>0</Data> 
  <Data>ecd2c9a5-1-128904882075773124</Data> 
  <Data>Full</Data> 
  <Data>/WebSite1</Data> 
  <Data>C:\Users\XXX\Documents\Visual Studio 2008\WebSites\WebSite1\</Data> 
  <Data>XXX</Data> 
  <Data /> 
  <Data>6404</Data> 
  <Data>WebDev.WebServer.EXE</Data> 
  <Data>XXX</Data> 
  <Data>Exception</Data> 
  <Data>Foo%20Bar</Data> 
  <Data>http://localhost:6594/WebSite1/Default.aspx</Data> 
  <Data>/WebSite1/Default.aspx</Data> 
  <Data>127.0.0.1</Data> 
  <Data>XXX</Data> 
  <Data>True</Data> 
  <Data>NTLM</Data> 
  <Data>XXX</Data> 
  <Data>4</Data> 
  <Data>XXX</Data> 
  <Data>False</Data> 
  <Data>at _Default.Page_Load(Object sender, EventArgs e) at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)</Data> 
</EventData>
</Event>

This looks fine. So it looks like the problem might be in the Event Viewer. What logic converts the XML event data into the formatted data under General?

看起来很好。所以看起来问题可能出在事件查看器中。什么逻辑将XML事件数据转换为General下的格式化数据?

1 个解决方案

#1


Unless someone else knows otherwise, I'll have to say that this sounds like a bug.

除非别人知道,否则我不得不说这听起来像个错误。

If so, then please report this at http://connect.microsoft.com/visualstudio/. Please search first to see if it's already been reported. Then, edit your question to include the URL of the bug report. That way, anyone reading this can vote on how important they feel this bug is to fix.

如果是,请在http://connect.microsoft.com/visualstudio/上报告。请先搜索一下是否已经报告过。然后,编辑您的问题以包含错误报告的URL。这样,任何阅读此内容的人都可以投票决定他们认为这个bug有多重要。

#1


Unless someone else knows otherwise, I'll have to say that this sounds like a bug.

除非别人知道,否则我不得不说这听起来像个错误。

If so, then please report this at http://connect.microsoft.com/visualstudio/. Please search first to see if it's already been reported. Then, edit your question to include the URL of the bug report. That way, anyone reading this can vote on how important they feel this bug is to fix.

如果是,请在http://connect.microsoft.com/visualstudio/上报告。请先搜索一下是否已经报告过。然后,编辑您的问题以包含错误报告的URL。这样,任何阅读此内容的人都可以投票决定他们认为这个bug有多重要。