title: WCF REST Service POST returns 404 Not Found on IIS
body: <p>I have a WCF service created with VS2012 on Win8. If I start the service via VS (localhost:port) I'm able to do GET's and POST's. When I deploy to IIS on the same machine only GET works. The POST return 404 Not Found. I've tried deploying directly to IIS by creating an application off of my Default Web Site as well as using VS Publish.</p>
  
  <p>POST URL: <a href="http://www.server.com/RestService/RestServiceImpl.svc/auth" rel="nofollow">http://www.server.com/RestService/RestServiceImpl.svc/auth</a></p>
  
  <p>POST Request Header: contents of PostData.xml below</p>
  
  <p>Web.config:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration&gt;
  
  &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.0" /&gt;
      &lt;customErrors mode="Off"/&gt;
  &lt;/system.web&gt;
  
  &lt;system.serviceModel&gt;
      &lt;services&gt;
        &lt;service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour"&gt;
            &lt;!-- Service Endpoints --&gt;
            &lt;!-- Unless fully qualified, address is relative to base address supplied above --&gt;
            &lt;endpoint address="" binding="webHttpBinding" contract="RestService.IRestServiceImpl" behaviorConfiguration="RestServiceImplEndpointBehavior"&gt;
                &lt;!-- Upon deployment, the following identity element should be removed or replaced to reflect the 
                     identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity automatically. --&gt;
            &lt;/endpoint&gt;
         &lt;/service&gt;
      &lt;/services&gt;
  
      &lt;behaviors&gt;
          &lt;serviceBehaviors&gt;
              &lt;behavior name="ServiceBehaviour"&gt;
                  &lt;!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --&gt;
                  &lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /&gt;
                  &lt;!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information --&gt;
                  &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
              &lt;/behavior&gt;
          &lt;/serviceBehaviors&gt;
          &lt;endpointBehaviors&gt;
              &lt;behavior name="RestServiceImplEndpointBehavior"&gt;
                  &lt;webHttp /&gt;
              &lt;/behavior&gt;
          &lt;/endpointBehaviors&gt;
      &lt;/behaviors&gt;
  
      &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true"/&gt;
      &lt;/system.serviceModel&gt;
  
      &lt;system.webServer&gt;
          &lt;modules runAllManagedModulesForAllRequests="true" /&gt;
          &lt;directoryBrowse enabled="true" /&gt;
      &lt;/system.webServer&gt;
  
      &lt;system.diagnostics&gt;
          &lt;sources&gt;
              &lt;source name="System.ServiceModel" 
                  switchValue="Information, ActivityTracing"
                  propagateActivity="true"&gt;
                  &lt;listeners&gt;
                      &lt;add name="traceListener" 
                          type="System.Diagnostics.XmlWriterTraceListener" 
                          initializeData= "c:\log\Traces.svclog" /&gt;
                  &lt;/listeners&gt;
              &lt;/source&gt;
          &lt;/sources&gt;
      &lt;/system.diagnostics&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>iRestServerImpl.cs:</p>
  
  <pre><code>using System.ServiceModel;
  using System.ServiceModel.Web;
  
  namespace RestService
  {
  
      [ServiceContract]
      public interface IRestServiceImpl
      {
          [OperationContract]
          [WebInvoke(Method = "GET",
              ResponseFormat = WebMessageFormat.Xml,
              BodyStyle = WebMessageBodyStyle.Wrapped,
              UriTemplate = "xml/{id}")]
          string XMLData(string id);
  
          [OperationContract]
          [WebInvoke(Method = "GET",
              ResponseFormat = WebMessageFormat.Json,
              BodyStyle = WebMessageBodyStyle.Wrapped,
              UriTemplate = "json/{id}")]
          string JSONData(string id);
  
          [OperationContract]
          [WebInvoke(Method = "POST",
              ResponseFormat = WebMessageFormat.Xml,
              RequestFormat = WebMessageFormat.Xml,
              BodyStyle = WebMessageBodyStyle.Bare,
              UriTemplate = "auth")]
          ResponseData Auth(RequestData rData);
  
      }
  }
  </code></pre>
  
  <p>RestServiceImpl.svc</p>
  
  <pre><code>&lt;%@ ServiceHost Language="C#" Debug="true" Service="RestService.RestServiceImpl" CodeBehind="RestServiceImpl.svc.cs" %&gt;
  </code></pre>
  
  <p>RestServiceImpl.svc.cs</p>
  
  <pre><code>namespace RestService
  {
      public class RestServiceImpl : IRestServiceImpl
      {
          #region IRestServiceImpl Members
  
          public string XMLData(string id)
          {
              return "You requested product " + id;
          }
  
          public string JSONData(string id)
          {
              return "You requested product " + id;
          }
  
          public ResponseData Auth(RequestData rData)
          {
              // Call BLL here
              var data = rData.details.Split('|');
              var response = new ResponseData
                                 {
                                     Name = data[0],
                                     Age = data[1],
                                     Exp = data[2],
                                     Technology = data[3]
                                 };
  
              return response;
          }
  
          #endregion
  
  
  
  
      }
  }
  </code></pre>
  
  <p>RequestData.cs</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Runtime.Serialization;
  using System.Text;
  
  namespace RestService
  {
      [DataContract(Namespace = "http://www.eysnap.com/mPlayer")]
      public class RequestData
      {
          [DataMember]
          public string details { get; set; }
      }
  }
  </code></pre>
  
  <p>ResponseData.cs</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Runtime.Serialization;
  using System.Web;
  
  namespace RestService
  {
      [DataContract]
      public class ResponseData
      {
          [DataMember]
          public string Name { get; set; }
  
          [DataMember]
          public string Age { get; set; }
  
          [DataMember]
          public string Exp { get; set; }
  
          [DataMember]
          public string Technology { get; set; }
      }
  }
  </code></pre>
  
  <p>PostData.xml</p>
  
  <pre><code>&lt;RequestData xmlns="http://www.eysnap.com/mPlayer"&gt;
    &lt;details&gt;Ashu|29|7 Years|.NET&lt;/details&gt;
  &lt;/RequestData&gt;
  </code></pre>