views:

248

answers:

1

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

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.

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:

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"&gt;
<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&lt;/Data&gt; 
  <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?

+1  A: 

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.

John Saunders
I have submitted it to https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=470598
Rasmus Faber
Microsoft have now acknowledged the bug and promised a fix for ASP.NET 4.0.
Rasmus Faber
Excellent! That's the way it's meant to work!
John Saunders