title: using Web Api in Webforms return 404 error
body: <p>I have an ASP.NET Webforms web site that includes Web API. The site is developed and tested with Visual Studio 2013 and .NET 4.5 on Windows 8 with IIS Express as web server.</p>
  
  <p>I have added the Web Api controller in the root directory that is defined as follows:</p>
  
  <pre><code>[RoutePrefix("api")]
  public class ProductsController : ApiController
  {
      Product[] products = new Product[] 
      { 
          new Product { Id = 1, Name = "Tomato Soup", Category = "Groceries", Price = 1 }, 
          new Product { Id = 2, Name = "Yo-yo", Category = "Toys", Price = 3.75M }, 
          new Product { Id = 3, Name = "Hammer", Category = "Hardware", Price = 16.99M } 
      };
      [Route("ProductsController")]
      [HttpGet]
      public IEnumerable&lt;Product&gt; GetAllProducts()
      {
          return products;
      }
  
      public Product GetProductById(int id)
      {
          var product = products.FirstOrDefault((p) =&gt; p.Id == id);
          if (product == null)
          {
              throw new HttpResponseException(HttpStatusCode.NotFound);
          }
          return product;
      }
  
      public IEnumerable&lt;Product&gt; GetProductsByCategory(string category)
      {
          return products.Where(
              (p) =&gt; string.Equals(p.Category, category,
                  StringComparison.OrdinalIgnoreCase));
      }
  }
  </code></pre>
  
  <p>The Global.asax looks like this:</p>
  
  <pre><code>public class Global : HttpApplication
  {
      void Application_Start(object sender, EventArgs e)
      {
          // Code that runs on application startup
          AreaRegistration.RegisterAllAreas();
          RouteConfig.RegisterRoutes(RouteTable.Routes);
  
  
          RouteTable.Routes.MapHttpRoute(
              name: "DefaultApi",
              routeTemplate: "api/{controller}/{id}",
              defaults: new { id = System.Web.Http.RouteParameter.Optional });
  
      }
  }
  </code></pre>
  
  <p>I have included these 2 lines in my web.config file</p>
  
  <pre><code>&lt;validation validateIntegratedModeConfiguration="false"/&gt;
  &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
  </code></pre>
  
  <p>When I make the get request with the following Url : <a href="http://localhost:5958/api/products" rel="nofollow">http://localhost:5958/api/products</a>, I get HTTP Error 404.0. I have tried different solutions but nothing works. Is there something that I'm missing? How do I rectify this problem?</p>
  
  <p>Thanks in advance.</p>