title: Throwing exceptions in ASP.NET Web API 'PUT' controller actions is inconsistent
body: <p>Does anyone know why the behaviour of throwing exceptions within a PUT action method in a controller in ASP.NET WebAPI would be different from any other actions and verb types?</p>
  
  <p>Essentially I have the code below (I normally have an exception filter globally registered but I've disabled that to ensure it isn't the cause).</p>
  
  <pre><code>public class JourneysController : ApiController
  {
      private IJourneyRepository repository = null;
  
      public JourneysController(IJourneyRepository repository)
      {
          this.repository = repository;
      }
  
      public async Task&lt;Journey&gt; GetById(string id)
      {
          throw new BusinessException("test1");
  
          var item = await repository.Get(id);
          if (item == null) throw new HttpResponseException(HttpStatusCode.NotFound);
          return item;
      }
  
      public async Task&lt;HttpResponseMessage&gt; Post(HttpRequestMessage request, [FromBody]Journey value)
      {
          throw new BusinessException("test2");
  
          value = await repository.Add(value);
  
          var response = request.CreateResponse&lt;Journey&gt;(HttpStatusCode.Created, value);
  
          string uri = Url.Link("DefaultApi", new { id = value.Id });
          response.Headers.Location = new Uri(uri);
          return response;
      }
  
      public async void Put(string id, [FromBody]Journey value)
      {
          throw new BusinessException("test3");
  
          value.Id = id;
          if (!await repository.Update(value)) throw new HttpResponseException(HttpStatusCode.NotFound);
      }
  
      public HttpResponseMessage Delete(string id)
      {
          throw new BusinessException("test4");
  
          repository.Remove(id);
          return new HttpResponseMessage(HttpStatusCode.NoContent);
      }
  }
  </code></pre>
  
  <p>When I execute (using Chrome Advanced REST client) the GET, POST and DELETE verbs I get a payload like the following (no easy way to copy/paste out of the client):</p>
  
  <pre><code>500 Internal Server Error 
  
  Date: Tue, 25 Sep 2012 15:37:56 GMT 
  X-AspNet-Version: 4.0.30319
  X-Powered-By: ASP.NET
  Content-Length: 813 
  Pragma: no-cache 
  
  {
      "Message": "An error has occurred.",
      "ExceptionMessage": "test4",
      "ExceptionType": "KieranBenton.LeaveNow.Services.Model.BusinessException",
      "StackTrace": " &lt;snip&gt;"
  }
  </code></pre>
  
  <p>However the PUT action returns me a yellow screen of death payload like:</p>
  
  <pre><code>&lt;span&gt;&lt;H1&gt;Server Error in '/' Application.&lt;hr width=100% size=1 color=silver&gt;&lt;/H1&gt;
  
          &lt;h2&gt; &lt;i&gt;test3&lt;/i&gt; &lt;/h2&gt;&lt;/span&gt;
  
          &lt;font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "&gt;
  
          &lt;b&gt; Description: &lt;/b&gt;An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
  
          &lt;b&gt; Exception Details:    &lt;/b&gt;KieranBenton.LeaveNow.Services.Model.BusinessException: test3
  </code></pre>
  
  <p>Has anyone got any idea why this might be happening or if I've actually stumbled across a bug?</p>
  
  <p>Thanks.</p>