title: Why does my Web API return 404 on all resources when called from a Console app?
body: <p>I have a little Web API, almost directly from the standard VS project template, i.e. <code>Home</code> and <code>Values</code> controllers, and lots of MVC cruft. It is set to run and debug under IIS 10.</p>
  
  <p>I have set up tracing by adding the package <code>Microsoft.AspNet.WebApi.Tracing</code> and the following code in <code>WebApiConfig</code>: </p>
  
  <pre><code>    public static void Register(HttpConfiguration config)
      {
          config.EnableSystemDiagnosticsTracing();
          SystemDiagnosticsTraceWriter traceWriter = config.EnableSystemDiagnosticsTracing();
          traceWriter.IsVerbose = true;
          traceWriter.MinimumLevel = TraceLevel.Debug;
          config.Services.Replace(typeof(ITraceWriter), new SimpleTracer());
          ...
          ...            
      }
  </code></pre>
  
  <p><code>SimpleTracer</code> is an <code>ITraceWriter</code> that writes to a text file.</p>
  
  <p>When I call the API from outside the VS ecosystem, i.e. from PostMan in Chrome, a bad url, that results in a 404 error message, and the creation of a new trace file if there's not already one. Of I call it from PostMan with a good url, I get the expected result, and a trace of the request in the trace file.</p>
  
  <p>When I call it from my Console app, even with a good url, I still get a 404 error response, and nothing is written to the trace file. I made sure by removing it and IIS doesn't even re-create it when using the <code>.exe</code> client.</p>
  
  <p>If I call it from the compiled <code>.exe</code> from outside VS, I get the same error.</p>
  
  <p>Then, when I set the Web API to use IIS Express, everything works perfectly. Do I need CORS for calls from non-web apps, does IIS need an extra header in this case? What is wrong?</p>
  
  <p><strong>EDIT A:</strong> This is the request when I use PostMan, and it returns a 200 and the expected list of strings.</p>
  
  <pre><code>GET /DemoApi/api/values HTTP/1.1
  Host: localhost
  Content-Type: application/json
  Cache-Control: no-cache
  Postman-Token: f9454ffc-6a8d-e1ed-1a28-23ed8166e534
  </code></pre>
  
  <p>and the response and headers:</p>
  
  <pre><code>["value1","value2","value3","value4","value5","value6","value7"]
  
  Cache-Control →no-cache
  Content-Length →64
  Content-Type →application/json; charset=utf-8
  Date →Tue, 13 Dec 2016 06:20:07 GMT
  Expires →-1
  Pragma →no-cache
  Server →Microsoft-IIS/10.0
  X-AspNet-Version →4.0.30319
  X-Powered-By →ASP.NET
  </code></pre>
  
  <p><strong>EDIT B:</strong> This is the request sent using HttpClient:</p>
  
  <pre><code>GET http://abbeyofthelema/api/values HTTP/1.1
  Accept: application/json
  Host: abbeyofthelema
  Connection: Keep-Alive
  </code></pre>
  
  <p>The only real difference is that because Fiddler doesn't capture traffic from localhost, I had to use my computer name instead. The same recipient still gets the request.</p>
  
  <p>The response here is:</p>
  
  <pre><code>HTTP/1.1 404 Not Found
  Cache-Control: private
  Content-Type: text/html; charset=utf-8
  Server: Microsoft-IIS/10.0
  X-Powered-By: ASP.NET
  Date: Tue, 13 Dec 2016 08:07:25 GMT
  Content-Length: 4959
  </code></pre>