title: C# - MVC ApiController routing only returns a 404
body: <p>I am trying to build a simple API using MVC <code>ApiControllers</code>. But it seems that my routing is incorrect, because I always get a <code>404</code> response code when I hit my endpoint.</p>
  
  <p>I have the <code>ApiController</code> code:</p>
  
  <pre><code>namespace MyProject.Web.Controllers
  {
      public class TestController : ApiController
      {
          [AllowAnonymous]
          [Route("test")]
          public IHttpActionResult Test() {
              return Ok();
          }
      }
  }
  </code></pre>
  
  <p>And my WebApiConfig.cs is:</p>
  
  <pre><code>namespace MyProject.Web 
  {
      public static class WebApiConfig
      {
          public static void Register(HttpConfiguration config) 
          {
              // Web API routes
              config.MapHttpAttributeRoutes();
  
              config.Routes.MapHttpRoute(
                  name: "DefaultApi",
                  routeTemplate: "api/{controller}/{id}",
                  defaults: new { id = RouteParameter.Optional }
              );
  
              var jsonFormatter = config.Formatters.OfType&lt;JsonMediaTypeFormatter&gt;().First();
              jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
          }
      }
  }
  </code></pre>
  
  <p>When I go to the endpoint <code>http://localhost:7248/test</code> I get a <code>404</code> (NOT FOUND) error.
  I've also tried removing <code>config.MapHttpAttributeRoutes();</code> and hitting the url <code>http://localhost:7248/api/test/test</code> but I still see a <code>404</code>.</p>
  
  <p>I can't seem to make this work regardless of what I try. Does anyone see any place that I am going wrong?</p>