title: how to call controller/action from button click in mvc 4
body: <p>I have a simple login screen. On click of button i want to call LoginUser action defined in Home controller. I am getting HTTP 404, resource not found error. The address bar after clicking the button shows "<a href="http://localhost:13805/Home/LoginUser" rel="nofollow">http://localhost:13805/Home/LoginUser</a>". I am not sure what i am doing wrong here. Really appreciate any help on this. </p>
  
  <p>Here is the button:</p>
  
  <pre><code>&lt;button type="submit" onclick="location.href='@Url.Action("LoginUser", "Home")'" class="btn btn-default"&gt;Submit&lt;/button&gt;
  </code></pre>
  
  <p>and here is the action defined in Home controller:</p>
  
  <pre><code>[HttpPost]
      public ActionResult LoginUser(string username, string password)
      {
          bool loginSuccess = false;
          if (!HttpContext.User.Identity.IsAuthenticated)
          {
              AuthenticationMode = System.Configuration.ConfigurationManager.AppSettings["AuthenticationMode"];
              if (AuthenticationMode.Equals("Forms"))
              {
                  int userId = CheckUserLogin(username);
                  if (userId &gt; 0)
                  {
                      CurrentUserId = userId;
                      FormsAuthentication.SetAuthCookie(username, false);
                      LoadMenu();
                      loginSuccess = true;
                  }
                  else
                  {
                      loginSuccess = false;
                  }
              }
              else
              {
                  loginSuccess = false;
              }
          }
          else
          {
              loginSuccess = true;
          }
  
          if (loginSuccess)
          {
              return RedirectToAction("Index", "home");
          }
          else
          {
              return RedirectToAction("Login", "home");
          }            
      }
  </code></pre>