title: Method not found in Web API 2
body: <p>Im trying to figure out how to use Web API. I have gone through some tutorials and now Im trying to set up my web service. 
  I have a really hard time trying to figure out why it cant find my methods. To me it just seems like random (the tutorials worked fine). 
  During my experiments sometimes the get method returns "method not allowed".</p>
  
  <p>This is my service:</p>
  
  <pre><code>public class ContentFilesController : ApiController
  {
    [Route("api/contentfile/{id}")]
      [HttpGet]
      public IHttpActionResult GetContentFiles(int count)
      {
          if (_contentFiles == null)
              GenerateContentFileList();
          List&lt;ContentFile&gt; files = new List&lt;ContentFile&gt;();
          int i = 0;
          while(true)
          {
              ContentFile cf = _contentFiles[i];
              if(!_filesOutForProcessing.Contains(cf))
              {
                  files.Add(cf);
                  i++;
              }
              if (i == count)
                  break;
          }
          return Ok(files);
      }
      [HttpPost]
      [Route("api/contentfile/{files}")]
      public IHttpActionResult Post([FromBody] List&lt;ContentFile&gt; files)
      {
          return Ok();
      }
  </code></pre>
  
  <p>}</p>
  
  <p>Edit:
  This is the code I am using to call the service:</p>
  
  <pre><code>static async Task TestAsync()        {
          using (var client = new HttpClient())            {
              client.BaseAddress = new Uri("http://localhost:46015/");
              client.DefaultRequestHeaders.Accept.Clear();
              client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
              HttpResponseMessage response = await client.GetAsync("api/contentfile/1");
              if (response.IsSuccessStatusCode)
              {
                  var contentfiles = await response.Content.ReadAsAsync&lt;List&lt;ContentFile&gt;&gt;();                    
              }
          }
      }
  
      static async Task ReportTest()
      {
          List&lt;ContentFile&gt; files = new List&lt;ContentFile&gt;()
          {
              new ContentFile(){Path="hej"},
              new ContentFile(){Path="då"}
          };
  
          using(var client = new HttpClient())
          {
              client.BaseAddress = new Uri("http://localhost:46015");
              client.DefaultRequestHeaders.Accept.Clear();
              client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
              HttpResponseMessage response = await client.PostAsJsonAsync&lt;List&lt;ContentFile&gt;&gt;("api/contentfile", files);
              if(response.IsSuccessStatusCode)
              {
  
              }
          }
      }
  </code></pre>
  
  <p>Where do you start looking? 
  Im going crazy here. </p>
  
  <p>Thanks!</p>
  
  <p>Edit: to clarify the error, the problem with both client methods are that the  HttpResponseMessage has response.IsSuccessStatusCode false and the StatusCode = MethodNotAllowed or MethodNotFound. </p>