title: Elmah not logging exceptions for http post requests in MVC app - if the request contains XML
body: <p>I've come across a weird problem in my MVC4 (RC) application. (running on .NET 4.0)</p>
  
  <p>I have just setup Elmah for logging exceptions / errors.</p>
  
  <p>I basically installed the <strong>Elmah.MVC</strong> and <strong>elmah.sqlserver</strong> NuGet packages. (versions 2.0.0 and 1.2 respectively)</p>
  
  <p>It seemed to work fine out of the box - I can go to the elmah page and view errors:</p>
  
  <p><code>http://myserver/elmah</code></p>
  
  <p>for example, if I create some 404 errors, they appear in this log.</p>
  
  <p>What is not working is this:  I have a standard MVC controller with a <code>[HttpPost]</code> action. I've set it up so it will always throw an exception:</p>
  
  <pre><code>public class TestController : Controller
  {
      [HttpPost]
      [ValidateInput(false)]
      public void Testing()
      {
          throw new Exception("uh oh");
      }
  }
  </code></pre>
  
  <p>I then try to post data to this controller via jQuery:</p>
  
  <pre><code>$.post('/Test/Testing', {test_data: 'This is some test data'});
  </code></pre>
  
  <p>Ok, this works. The response returns the typical yellow screen of death, and the error is caught and logged in Elmah.</p>
  
  <p>However, if I try to post something like XML/HTML the error is <strong>not</strong> logged in Elmah. I still get the same response from the server back (yellow screen of death), but nothing in Elmah.</p>
  
  <pre><code>$.post('/Test/Testing', {test_data: '&lt;test&gt;&lt;test1&gt;This is some test data&lt;/test1&gt;&lt;/test&gt;'});
  </code></pre>
  
  <p>Why? It doesn't make sense.</p>
  
  <p>Notice I have already turned off the request validation on the action. If I didn't do that, then posting XML/HTML data would cause this exception:</p>
  
  <p><strong><em>A potentially dangerous Request.Form value was detected from the client</em></strong></p>
  
  <p>NuGet would also refuse to log that exception too - which I believe is a bug:</p>
  
  <p><a href="http://code.google.com/p/elmah/issues/detail?id=217" rel="noreferrer">http://code.google.com/p/elmah/issues/detail?id=217</a></p>
  
  <p>So what is the cause of this problem that I'm experiencing? It it a bug related to the issue I found above?</p>
  
  <p>It just seems quite an unfortunate situation that I can't log exceptions just because the request contained XML/HTML.</p>
  
  <p>Surely there is a way around this?</p>