title: HttpClient Call to WebApi Service on IIS 7.5 - 404 Not Found
body: <p>I am new to WebApi and we have a requirement to create\maintain a token issuing web service. A colleague of mine provided his solution (beta) which he has allowed me to use. If I run the web service from my dev environment (VS 2012) I am able to query it and get the token back from a web browser (Chrome). I then wrote a test app to use HttpClient to query the service and get the token. This works fine from the service hosted in my dev environment but if I try to query it when hosted in IIS using my little test app I get a '404 Not Found' exception. But what is puzzling me is if I connect to the web service hosted in IIS from chrome it works?</p>
  
  <p>My controller method is as follows:</p>
  
  <pre><code>[HttpGet]
  public IHttpActionResult GetToken(string username, string password, string realm)
  {            
      return Json("TOKEN-STRING");
  }
  </code></pre>
  
  <p>And my config:</p>
  
  <pre><code>&lt;system.webServer&gt;
  &lt;validation validateIntegratedModeConfiguration="false" /&gt;    
  &lt;modules runAllManagedModulesForAllRequests="true"&gt;
    &lt;remove name="UrlRoutingModule-4.0" /&gt;
    &lt;add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" /&gt;
  &lt;/modules&gt;
  &lt;handlers&gt;
    &lt;remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" /&gt;
    &lt;remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" /&gt;
    &lt;remove name="ExtensionlessUrlHandler-Integrated-4.0" /&gt;
    &lt;remove name="OPTIONSVerbHandler" /&gt;
    &lt;remove name="TRACEVerbHandler" /&gt;
    &lt;add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /&gt;
    &lt;add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,PUT,DELETE,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /&gt;
    &lt;add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,PUT,DELETE,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" /&gt;
  &lt;/handlers&gt;
  </code></pre>
  
  <p></p>
  
  <p>I have set my application pool to 'Integrated' within IIS.</p>
  
  <p>My logic says to me that if I am able to retrieve the token from Chrome but not from my app, then there should be nothing wrong with IIS but rather a config\setting\programming error in my app.</p>
  
  <p>Here is the little method I wrote to get the token:</p>
  
  <pre><code>async private void GetToken()
      {
          HttpClient client = new HttpClient();
  
          client.BaseAddress = new Uri("http://localhost/TokenServer/");
          client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  
          var response = client.GetAsync("/api/TokenServer/GetToken/name/password/realm").Result;
          string result =  await response.Content.ReadAsStringAsync();
  
          if (!response.IsSuccessStatusCode)
          {
              //Error handling
              return;
          }
  
          //Extract token from response
          JavaScriptSerializer json_serializer = new JavaScriptSerializer();
          Token = DeserializeJsonToken(result);
      }
  </code></pre>
  
  <p>I have read and tried many suggestions but none seem to work for me. I have been stuck with this for two days now and the deadline is creeping :)</p>
  
  <p>Tx</p>