title: Not getting REST WCF BadRequest error message in .NET 3.5
body: <p>I have a REST WCF application developed in .NET 3.5.</p>
  
  <p>To check for invalid request url like say for example missing parameters, etc. I am using a class which implements the "IErrorHandler" interface. So inside that class I have this section of code which is supposed to generate a BadRequest error code and message :</p>
  
  <pre><code>public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
          {
              ExceptionHelper.HandleException(error, Severity.Error);
              StatusResponseBE statusResponseEntity = new StatusResponseBE();
              statusResponseEntity.Code = STATUS_CODE_FAIL;
              statusResponseEntity.Message = "Failed to perform requested operation";
              statusResponseEntity.Errors = new ErrorResponseBECollection();
  
              if (error is SerializationException || error is InvalidOperationException)
              {
                  statusResponseEntity.Errors.Add(new ErrorResponseBE()
                  {
                      Code = EX_INVALID_REQUEST_CODE,
                      Description = "Invalid Request"
                  });
                  fault = Message.CreateMessage(version, string.Empty, statusResponseEntity, new DataContractJsonSerializer(typeof(StatusResponseBE)));
                  fault.Properties.Add(WebBodyFormatMessageProperty.Name, new WebBodyFormatMessageProperty(WebContentFormat.Json));
                  WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.BadRequest;
                  return;
              }
              else
              {
                  statusResponseEntity.Errors.Add(new ErrorResponseBE()
                  {
                      Code = EX_INTERNAL_ERROR_CODE,
                      Description = "Internal Error"
                  });
                  fault = Message.CreateMessage(version, string.Empty, statusResponseEntity, new DataContractJsonSerializer(typeof(StatusResponseBE)));
                  fault.Properties.Add(WebBodyFormatMessageProperty.Name, new WebBodyFormatMessageProperty(WebContentFormat.Json));
                  WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.InternalServerError;
                  return;
  
              }
  
          }
  </code></pre>
  
  <p>But when I am hitting my WCF service with invalid request URL, I am getting a BadReqest error code as 400, but not message in the response JSON like something as "Code : 400 ; Message : Invalid Request"</p>
  
  <pre><code>HTTP/1.1 400 Bad Request
  Cache-Control: private
  Content-Type: application/xml; charset=utf-8
  Server: Microsoft-IIS/7.0
  Access-Control-Allow-Origin: *
  X-AspNet-Version: 2.0.50727
  Set-Cookie: ASP.NET_SessionId=xz412e35vruepr45qjrp5lyw; path=/; HttpOnly
  X-Powered-By: ASP.NET
  Date: Thu, 03 May 2012 14:47:15 GMT
  Content-Length: 1165
  
  &lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;HTML&gt;&lt;HEAD&gt;&lt;STYLE type="text/css"&gt;#content{ FONT-SIZE: 0.7em; PADDING-BOTTOM: 2em; MARGIN-LEFT: 30px}BODY{MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR: #000000; FONT-FAMILY: Verdana; BACKGROUND-COLOR: white}P{MARGIN-TOP: 0px; MARGIN-BOTTOM: 12px; COLOR: #000000; FONT-FAMILY: Verdana}PRE{BORDER-RIGHT: #f0f0e0 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #f0f0e0 1px solid; MARGIN-TOP: -5px; PADDING-LEFT: 5px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 5px; BORDER-LEFT: #f0f0e0 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: #f0f0e0 1px solid; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e5e5cc}.heading1{MARGIN-TOP: 0px; PADDING-LEFT: 15px; FONT-WEIGHT: normal; FONT-SIZE: 26px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 3px; MARGIN-LEFT: -30px; WIDTH: 100%; COLOR: #ffffff; PADDING-TOP: 10px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #003366}.intro{MARGIN-LEFT: -15px}&lt;/STYLE&gt;
  &lt;TITLE&gt;Request Error&lt;/TITLE&gt;&lt;/HEAD&gt;&lt;BODY&gt;
  &lt;DIV id="content"&gt;
  &lt;P class="heading1"&gt;Request Error&lt;/P&gt;
  &lt;BR/&gt;
  &lt;P class="intro"&gt;The server encountered an error processing the request. See server logs for more details.&lt;/P&gt;
  &lt;P class="intro"&gt;&lt;/P&gt;
  &lt;/DIV&gt;
  &lt;/BODY&gt;&lt;/HTML&gt;
  </code></pre>
  
  <p>Instead I am getting the above in tha Raw tab in Fiddler.</p>
  
  <p>Any idea why this is happening and what I can do to solve it? It's been bugging me a lot and I have tried everything but it doesn't seem to work the say it should.</p>