title: Hosting REST WCF 3.5 on IIS 6 with webHTTPBinding gives 400 "Bad Request" and Login Failure error 1380 in IIS log
body: <p>I'm learning WCF and have the following code working in my dev environment using visual studio 2008 and its web server. When I publish the web service to IIS 6, all requests result in 400 "Bad Request" error. Looking at the IIS log, the status code is 400 and the win32-status code is 1380. Using <code>net helpmsg 1380</code>, it tells me that wind32 status code means "<strong>Logon failure: the user has not been granted the requested logon type at this computer</strong>." But I'm using <strong>webHTTPBinding</strong> for REST which doesn't use authentication or security method.</p>
  
  <p>In IIS, I have the application set to allow anonymous which is set to impersonate "IUSER_&lt;machine_name&gt;" account. In the application pool, I have it set to use the Network Service identity. Both users are setup to write access temp folders as well as the .net framework folders. I've setup WCF tracing, but the logs are blank. I'm banging my head against the wall. Can someone please help?</p>
  
  <p>System.ServiceModel portion of the web.config:</p>
  
  <pre><code> &lt;system.serviceModel&gt;
    &lt;behaviors&gt;
     &lt;endpointBehaviors&gt;
      &lt;behavior name="web"&gt;
       &lt;webHttp /&gt;
      &lt;/behavior&gt;
     &lt;/endpointBehaviors&gt;
     &lt;serviceBehaviors&gt;
      &lt;behavior name="default"&gt;
       &lt;serviceMetadata /&gt;
      &lt;/behavior&gt;
     &lt;/serviceBehaviors&gt;
    &lt;/behaviors&gt;
    &lt;services&gt;
     &lt;service behaviorConfiguration="default" name="GTKK.ServiceLibrary.GTKKService"&gt;
      &lt;endpoint address="" behaviorConfiguration="web" binding="webHttpBinding"
       bindingConfiguration="" name="web" contract="GTKK.ServiceLibrary.IGTKKService" /&gt;
      &lt;endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
       name="mex" contract="IMetadataExchange" /&gt;
      &lt;host&gt;
       &lt;baseAddresses&gt;
        &lt;add baseAddress="http://localhost:1173/GTKKService" /&gt;
       &lt;/baseAddresses&gt;
      &lt;/host&gt;
     &lt;/service&gt;
    &lt;/services&gt;
    &lt;diagnostics&gt;
     &lt;messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true"
      logMessagesAtTransportLevel="true" /&gt;
    &lt;/diagnostics&gt;
   &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>Here's my Service contract:</p>
  
  <pre><code>using GTKK.DTO;
  using System.ServiceModel.Web;
  
  namespace GTKK.ServiceLibrary
  {
      [ServiceContract(SessionMode=SessionMode.Allowed)]
      public interface IGTKKService
      {
          [WebGet(UriTemplate = "artist/{id}/json", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
          [OperationContract]
          ArtistDTO GetArtistByID(string id);
  
          [WebGet(UriTemplate = "artists/json?namefilter={namefilter}", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
          [OperationContract]
          List&lt;ArtistDTO&gt; GetArtistListByNameFilter(string nameFilter);
  
          [WebGet(UriTemplate = "localevents/json?search={searchText}", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
          [OperationContract]
          List&lt;EventDTO&gt; GetLocalEventsBySearchLocationJson(string searchText);
  
          [WebGet(UriTemplate = "localevents/xml?search={searchText}", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Xml)]
          [OperationContract]
          List&lt;EventDTO&gt; GetLocalEventsBySearchLocationXml(string searchText);
      }
  }
  </code></pre>
  
  <p>In browser, I use the following URL for testing in my dev environment using VS2008 web server and it works:</p>
  
  <pre><code>http://localhost:1173/GTKKService/localevents/xml?search=98101
  </code></pre>
  
  <p>After publishing to IIS and use the following url, I get the bad request page:</p>
  
  <pre><code>http://&lt;host_name&gt;/service.svc/localevents/xml?search=98101
  </code></pre>
  
  <p>I know that the url should be correct as if I put in a faulty url after the .svc part, I'll get an endpoint not found error, which is working the way it should. For example:</p>
  
  <pre><code>http://&lt;host_name&gt;/service.svc/anythinghere
  </code></pre>
  
  <p>The IIS server box has .net 2, 3.0, and 3.5 installed. The IIS web application is setup to use .net 2 (which will use .net 3.5). I've also ran serviceModelReg /i /x as well as with /ia to make sure WCF is installed and registered. The thing about the "Bad Request" error page is that it's not the IIS error page, it's HTML formatted like a WCF error page with the navy blue bar across the top with the white title "<strong>Request Error</strong>", followed by the message "<strong>The server encountered an error processing the request. See server logs for more details.</strong>"</p>
  
  <p>Please help.</p>