title: unable to call web api using custom methods
body: <p>I followed some answers but getting the following error on postman</p>
  
  <p><code>{
    "Message": "The requested resource does not support http method 'GET'."
  }</code> </p>
  
  <p>these were the links i followed</p>
  
  <p><a href="https://stackoverflow.com/questions/18661946/web-api-route-to-action-name">Web API route to action name</a></p>
  
  <p><a href="https://stackoverflow.com/questions/24843264/how-to-add-custom-methods-to-asp-net-webapi-controller">How to add custom methods to ASP.NET WebAPI controller?</a></p>
  
  <p>currently setup is like the one as sky-dev has described</p>
  
  <p><a href="https://stackoverflow.com/questions/9569270/custom-method-names-in-asp-net-web-api">Custom method names in ASP.NET Web API</a></p>
  
  <p><strong>Updated with code</strong></p>
  
  <p>webapiconfig.cs</p>
  
  <pre><code>public static void Register(HttpConfiguration config)
      {
          // Web API configuration and services
          // Configure Web API to use only bearer token authentication.
          //config.SuppressDefaultHostAuthentication();
          //config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
  
          //// Web API routes
          //config.MapHttpAttributeRoutes();
  
          //config.Routes.MapHttpRoute(
          //    name: "DefaultApi",
          //    routeTemplate: "api/{controller}/{id}",
          //    defaults: new { id = RouteParameter.Optional }
          //);
          config.Routes.MapHttpRoute("DefaultApiWithId", "api/{controller}/{id}", new { id = RouteParameter.Optional }, new { id = @"\d+" });
          config.Routes.MapHttpRoute("DefaultApiWithAction", "api/{controller}/{action}");
          config.Routes.MapHttpRoute(name: "ApiWithActionName",routeTemplate: "api/{controller}/{action}/{id}",defaults: new { id = RouteParameter.Optional });
          config.Routes.MapHttpRoute("DefaultApiGet", "api/{controller}", new { action = "Get" }, new { httpMethod = new HttpMethodConstraint(HttpMethod.Get) });
          config.Routes.MapHttpRoute("DefaultApiPost", "api/{controller}", new { action = "Post" }, new { httpMethod = new HttpMethodConstraint(HttpMethod.Post) });
  
      }
  </code></pre>
  
  <p>defaultcontroller.cs</p>
  
  <pre><code>public class DefaultController : ApiController
  {
      DBEntities db = new DBEntities();
      public IEnumerable&lt;CategoryDTO&gt; Category()
      {
          IEnumerable&lt;CategoryDTO&gt; List = from tr in db.Categories
                                                    where tr.IsActive == "Y"
                                                    orderby tr.DisplayOrder ascending
                                                    select new CategoryDTO()
                                                    {
                                                        Id = tr.Id,
                                                        Name = tr.Name
                                                    };
          return List;
      }
      // GET: api/Default
      public IEnumerable&lt;string&gt; Get()
      {
          return new string[] { "value1", "value2" };
      }
  
      // GET: api/Default/5
      public string Get(int id)
      {
          return "value";
      }
  
      // POST: api/Default
      public void Post([FromBody]string value)
      {
      }
  
      // PUT: api/Default/5
      public void Put(int id, [FromBody]string value)
      {
      }
  
      // DELETE: api/Default/5
      public void Delete(int id)
      {
      }
  
  
  }
  </code></pre>