title: Web Api Get() route not working when return type is HttpResponseMessage
body: <p>This is causing me a bit of a headache. Ultimately, I'm trying to return an image but I've been experimenting and simplified this to using  a string.</p>
  
  <p>What I want:
  go to URL: </p>
  
  <pre><code>http://xxx/api/helloworld/1
  </code></pre>
  
  <p>Responds with: "Hello world!"</p>
  
  <p>The following web api declarations work for the url supplied;</p>
  
  <pre><code>public string Get([FromUri]int id) { return "Hello World"; }
  public Task&lt;string&gt; Get([FromUri]int id) { return "Hello World"; }
  </code></pre>
  
  <p>What does NOT work;</p>
  
  <pre><code>public HttpResponseMessage Get([FromUri]int id) 
  { 
      return Request.CreateResponse&lt;string&gt;(HttpStatusCode.OK, "Hello World");
  }
  
  public HttpResponseMessage Get([FromUri]int id)
  {
      HttpResponseMessage response = new HttpResponseMessage();
  
      string text = "Hello World";
      MemoryStream test = new MemoryStream();
      test.Write(ConversionUtilities.ToBytes(text) /*custom string-&gt;byte[] method, UTF-8 encoding*/, 0, text.Length);
  
      response.Content = new StreamContent(test);
      response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/plain");
      response.StatusCode = HttpStatusCode.OK;
  
      return response;
  }
  </code></pre>
  
  <p>What happens when I have a Get() with a return type of HttpResponseMessage is the following error is returned;</p>
  
  <pre><code>No HTTP resource was found that matches the request URI "http://xxx/api/helloworld/1"
  </code></pre>
  
  <p>This error only appears for this particular return type. Now, my routing in the WebApiConfig.cs file is as follows (and works for "string" return types);</p>
  
  <pre><code>// Controller with ID
  // To handle routes like "/api/VTRouting/1"
  config.Routes.MapHttpRoute(
      name: "ControllerAndId",
      routeTemplate: "api/{controller}/{id}",
      defaults: null,
      constraints: new { id = @"^\d+$" } // Only integers 
  );
  
  // Controllers with Actions
  // To handle routes like "/api/VTRouting/route"
  config.Routes.MapHttpRoute(
      name: "ControllerAndAction",
      routeTemplate: "api/{controller}/{action}"
  );
  
  // Controller Only
  // To handle routes like "/api/VTRouting"
  config.Routes.MapHttpRoute(
      name: "ControllerOnly",
      routeTemplate: "api/{controller}"
  );
  </code></pre>
  
  <p>Any thoughts? I'm stumped as to the return type behaviour :-S    </p>