title: Why can't navigate to web api controller
body: <p>I use Web API for the first time to connect my mobile app to Web API.<br/>
  I have MVC 5 project and I have created API folder and inside I have created <code>ProductsController</code>.</p>
  
  <pre><code>namespace DDD.WebUI.API
  {
      public class ProductsController : ApiController
      {
          public string GetAllProducts()
          {
              return "Hello From WebAPI";
          }
  
      }
  }
  </code></pre>
  
  <p>And I have tried to access this method from browser:</p>
  
  <pre><code>http://localhost:21879/DDD.WebUI/API/products/GetAllProducts
  </code></pre>
  
  <p>But I get 404.<br/>
  It's probably something stupid but can't figure it :(<br/>
  <strong>UPDATE</strong></p>
  
  <pre><code>public static void RegisterRoutes(RouteCollection routes)
          {
              routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  
              routes.MapRoute(
                 name: "DefaultApi",
                 url: "API/{controller}/{action}/{id}",
                 defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
             );
  
              routes.MapRoute(
                  name: "Default",
                  url: "{controller}/{action}/{id}",
                  defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
              );
  
  
  
          }
  </code></pre>
  
  <p><strong>UPDATE 2</strong><br/>
  I have a little progress:
  I have update <code>Application_Start()</code> with:</p>
  
  <pre><code>GlobalConfiguration.Configure(WebApiConfig.Register);
  RouteConfig.RegisterRoutes(RouteTable.Routes);
  </code></pre>
  
  <p>In <code>WebApiConfig</code> I have:</p>
  
  <pre><code>config.Routes.MapHttpRoute(
                  name: "DefaultApi",
                  routeTemplate: "api/{controller}/{id}",
                  defaults: new { id = RouteParameter.Optional }
              );
  </code></pre>
  
  <p>I still store API controller in Project/Api/ProductsController
  But now I can access it but still can't get value from it:</p>
  
  <pre><code>http://localhost:21879/api/products/getallproducts
  </code></pre>
  
  <p>But error I get is:</p>
  
  <pre><code>&lt;Error&gt;
  &lt;Message&gt;The request is invalid.&lt;/Message&gt;
  &lt;MessageDetail&gt;
  The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.String Get(Int32)' in 'GSL.WebUI.Api.ProductsController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
  &lt;/MessageDetail&gt;
  &lt;/Error&gt;
  </code></pre>