title: Can we create a custom uri to call different controller method functions
body: <p>I have bee going through various <a href="http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api" rel="nofollow noreferrer">MVC tutorials</a> and have also made a simple one.
  All of them only seem to address two kinds of uri to use. What if we want to use something other than 'controller' and 'id'? </p>
  
  <p>also how does it know which function is being called? the uri is <code>/api/products</code> but the function that returns value is <code>public IEnumerable&lt;Product&gt; GetAllProducts()</code></p>
  
  <p>Below is an example of a controller </p>
  
  <pre><code>using ProductsApp.Models;
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Net;
  using System.Web.Http;
  
  namespace ProductsApp.Controllers
  {
      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 } 
          };
  
          public IEnumerable&lt;Product&gt; GetAllProducts()
          {
              return products;
          }
  
          public IHttpActionResult GetProduct(int id)
          {
              var product = products.FirstOrDefault((p) =&gt; p.Id == id);
              if (product == null)
              {
                  return NotFound();
              }
              return Ok(product);
          }
  }
  </code></pre>
  
  <p>In this case I can only call the two functions in my web browser</p>
  
  <p><img src="https://i.stack.imgur.com/PEenl.jpg" alt="enter image description here"></p>
  
  <p>I wish to call uri that is somthing along the line of </p>
  
  <blockquote>
    <p>/api/products/foo</p>
  </blockquote>