title: Calling Web API from an aspx page is always resulting in Not Found error
body: <p>I have a web site project ( the one that has an App_Code folder) which I have upgraded to .Net 4.5, and installed NuGet package for Web API 2.2 into the solution in VS 2013.</p>
  
  <p>Under the root folder, there is a folder 'Vendors'. From a page under this folder, I am using jQuery to call a PUT Web API method inside a controller class 'AppsProcureWebApiController' under App_Code folder.</p>
  
  <p>Using the <code>url: 'api/AppsProcureWebApi'</code> in ajax call from jQuery always results in a 'Not Found error'.
  <img src="https://i.stack.imgur.com/bM2N8.png" alt="Not Found Error">
  But if I hard-code the url as <code>url:'http://localhost/appsprocure/api/AppsProcureWebApi'</code> in same jQuery ajax call then it works and  executes the code within the Web API method. </p>
  
  <p>Question: <strong>Do I need to use some special routing configuration in global.asax to make it work with orginal url, Or there is something else I need to do</strong>? (code being used for configuring routing in global.asax is mentioned below).</p>
  
  <p><strong>jQuery for calling Web API from /Vendors/EditProduct.aspx page</strong></p>
  
  <pre><code>function SaveProdDesc() {
              var data = {
                  productId: $find("&lt;%= radcomBoxProducts.ClientID%&gt;").get_value(),
                  productDescription: $("#&lt;%= txtProdDesc.ClientID%&gt;").val(),
                  originalProductDescription: $("#&lt;%= hfOrigProdDesc.ClientID%&gt;").val()
              }
              $.ajax({
                  url: 'api/AppsProcureWebApi',
                  type: 'PUT',
                  data: JSON.stringify(data),
                  contentType: "application/json",
                  dataType:"json",
                  success: function (data) {
                      alert(data);
                  },
                  error: function (x, y, z) {
                      alert(x + '\n' + y + '\n' + z);
                  }
              });
          }
  </code></pre>
  
  <p><strong>Routing defined in Global.asax</strong></p>
  
  <pre><code>    void Application_Start(object sender, EventArgs e)
      {
        //below code to make Web API work in Webforms
            RouteTable.Routes.MapHttpRoute( name: "DefaultApi", 
                 routeTemplate: "api/{controller}/{id}", 
                 defaults: new { id = System.Web.Http.RouteParameter.Optional });
  }
  </code></pre>
  
  <p><strong>Web API controller class under App_Code is as below.</strong></p>
  
  <pre><code>    public class AppsProcureWebApiController : ApiController
  {
      //OTHER METHODS ARE OMITTED TO SAVE SPACE
  
      [HttpPut]
      [Authorize]
      public int Put(ProductDesc p)
      {
          string prodDesc = p.ProductDescription;
          return ApplicationDataAccess.UpdateProductDescription(p.ProductId, ref prodDesc, p.OriginalProductDescription);
      }
  
  }
  
  public class ProductDesc
  {
      public long ProductId { get; set; }
      public string ProductDescription { get; set; }
      public string OriginalProductDescription { get; set; }
  }
  </code></pre>