title: Cannot reach Action in api Web API 2 Controller in MVC 5 app
body: <p>I've tried to follow default Web API tutorial: <a href="http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api" rel="nofollow noreferrer">http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api</a></p>
  
  <p>Here's what I did:</p>
  
  <p>1) I added Action Routing in my <code>WebApiConfig</code>:</p>
  
  <pre><code>config.Routes.MapHttpRoute(
     name: "ActionApi",
     routeTemplate: "api/{controller}/{action}/{id}",
     defaults: new { id = RouteParameter.Optional }
  );
  </code></pre>
  
  <p>2) I added a link on my nav bar with client side javascript call:</p>
  
  <pre><code>&lt;a onclick="RetrieveNext();" href="#"&gt;Retrieve next&lt;/a&gt;
  </code></pre>
  
  <p>3) Here's my view:</p>
  
  <pre><code>&lt;div class="row"&gt;
      &lt;div class="col-md-4"&gt;
          &lt;h2&gt;Next barcode&lt;/h2&gt;
          &lt;p id="barcode"&gt;
              No available barcode
          &lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;script&gt;
      var uri = 'api/Barcode';
  
      $(document).ready(function () {
      });
  
      function RetrieveNext() {
          uri = 'api/Barcode/RetrieveNext';
          $.getJSON(uri)
              .done(function (data) {
                  $('#barcode').text(data);
              })
              .fail(function (jqXHR, textStatus, err) {
                  $('#barcode').text('Error: ' + err);
              });
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>4) Here's my simple ApiController with 1 Action:</p>
  
  <pre><code>public class BarcodeController : ApiController
  {
      [HttpGet]
      public IHttpActionResult RetrieveNext()
      {
          string barcode = "123456";
          if (barcode == null)
          {
          return NotFound();
              }
          return Ok(barcode);
      }
  }
  </code></pre>
  
  <p>When I click my link I'm getting: <code>Error: Not Found</code> inside of my <code>&lt;p id="barcode"&gt;</code>, which means JavaScript works, but Action wasn't called.</p>
  
  <p>Here's Call details:</p>
  
  <p><img src="https://i.stack.imgur.com/sqKj6.png" alt="enter image description here"></p>
  
  <p>What I missed here? I put breakpoint in my Action and I can't reach this code...</p>