title: How do you return a custom 503 message?
body: <p>I have a service implemented in MVC4 / ASP.NET Web Api.  I would like to return a custom 503 message to my clients when the system is down for maintenance.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>    public class ServiceController : ApiController
      {
          public HttpResponseMessage&lt;ServiceUnavailableModel&gt; Get()
          {
              return new HttpResponseMessage&lt;ServiceUnavailableModel&gt;(new ServiceUnavailableModel(), HttpStatusCode.ServiceUnavailable);
          }
      }
  </code></pre>
  
  <p>My model looks like this:</p>
  
  <pre><code>    [Serializable]
      public class ServiceUnavailableModel : ISerializable
      {
          public ServiceUnavailableModel()
          {
              this.Message = Resources.SDE_SERVICE_UNAVAILABLE;
              this.Detail = Resources.SDE_SERVICE_REQUESTED_CURRENTLY;
              this.Code = (int)System.Net.HttpStatusCode.ServiceUnavailable;
          }
  
          public string Message { get; set; }
          public string Detail { get; set; }
          public int Code { get; set; }
  
          public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
          {
              info.AddValue("Message", this.Message);
              info.AddValue("Detail", this.Detail);
              info.AddValue("Code", this.Code);
          }
  
      }
  </code></pre>
  
  <p>This is simply what a bunch of my current API clients expect.  However, when I execute this action, I get the following result:</p>
  
  <pre><code>HTTP/1.1 503 Service Unavailable
  Cache-Control: no-cache
  Pragma: no-cache
  Content-Type: text/html
  Expires: -1
  Server: Microsoft-IIS/7.5
  X-AspNet-Version: 4.0.30319
  X-Powered-By: ASP.NET
  Date: Mon, 14 May 2012 20:22:39 GMT
  Content-Length: 200
  
  The service is unavailable.The service you requested is currently
  unavailable or undergoing maintenance. We will have the service back
  up and running shortly. Thank you for your patience.","Code":503}
  </code></pre>
  
  <p>Notice how it appears that my response was <em>partially</em> serialized.  What gives?</p>
  
  <p>PS.  I've tried Response.Clear() and Response.ClearContent() - no luck</p>