title: How to call a method in ApiController with http request?
body: <p>I have an ApiController named <code>Service</code>. I have a method named <code>UpdatePrice</code> in it. Now I want to send a http web request from another project to it by I receive 404 error code. And if I run it in browser I see this:</p>
  
  <pre><code>&lt;Error&gt;
      &lt;Message&gt;No HTTP resource was found that matches the request URI 'http://localhost:26769/api/service/updateprice?priceId=16&amp;cost=1234&amp;lastUpdate=2014-10-15 11:41:54.000'.&lt;/Message&gt;
      &lt;MessageDetail&gt;No type was found that matches the controller named 'service'.&lt;/MessageDetail&gt;
  &lt;/Error&gt;
  </code></pre>
  
  <p>This is the ApiController:</p>
  
  <pre><code>public class Service : ApiController
  {
      PriceApplication priceApp = new PriceApplication();
      public int UpdatePrice(int priceId,int cost,DateTime lastUpdate)
      {
          try
          {
              var price = priceApp.GetByPriceId(priceId);
              price.Cost = Convert.ToDecimal(cost);
              price.LastUpdate = lastUpdate;
              priceApp.Update(price);
              return cost;
          }
          catch
          {
              return -1;
          }
      }
  }
  </code></pre>
  
  <p>This is the routing for it:</p>
  
  <pre><code>routes.MapHttpRoute(
      name: "DefaultApi",
      routeTemplate: "api/{controller}/{action}/{id}",
      defaults: new { controller = "service",action="updateprice", id = RouteParameter.Optional}
  );
  </code></pre>
  
  <p>And this is the request:</p>
  
  <pre><code>string serviceUrl = string.Format("http://localhost:26769/api/service/updateprice?priceId={0}&amp;cost={1}&amp;lastUpdate={2}", priceId, cost, DateTime.Now);
  WebRequest request = WebRequest.Create(serviceUrl);
  WebResponse response = request.GetResponse();
  </code></pre>