title: MVC ajax post to controller action method
body: <p>I've been looking at the question here: <a href="https://stackoverflow.com/questions/4120212/mvc-ajax-json-post-to-controller-action-method">MVC ajax json post to controller action method</a> but unfortunately it doesn't seem to be helping me. Mine is pretty much the exact same, except my method signature (but I've tried that and it still doesn't get hit).</p>
  
  <h2>jQuery</h2>
  
  <pre><code>$('#loginBtn').click(function(e) {
      e.preventDefault();
  
      // TODO: Validate input
  
      var data = {
          username: $('#username').val().trim(),
          password: $('#password').val()
      };
  
      $.ajax({
          type: "POST",
          url: "http://localhost:50061/checkin/app/login",
          content: "application/json; charset=utf-8",
          dataType: "json",
          data: JSON.stringify(data),
          success: function(d) {
              if (d.success == true)
                  window.location = "index.html";
              else {}
          },
          error: function (xhr, textStatus, errorThrown) {
              // TODO: Show error
          }
      });
  });
  </code></pre>
  
  <h2>Controller</h2>
  
  <pre><code>[HttpPost]
  [AllowAnonymous]
  public JsonResult Login(string username, string password)
  {
      string error = "";
      if (!WebSecurity.IsAccountLockedOut(username, 3, 60 * 60))
      {
          if (WebSecurity.Login(username, password))
              return Json("'Success':'true'");
          error = "The user name or password provided is incorrect.";
      }
      else
          error = "Too many failed login attempts. Please try again later.";
  
      return Json(String.Format("'Success':'false','Error':'{0}'", error));
  }
  </code></pre>
  
  <p>However, no matter what I try, my <code>Controller</code> never gets hit. Through debugging, I know that it sends a request, it just gets a <code>Not Found</code> error each time.</p>