title: How to link HTML5 form action to Controller ActionResult method in ASP.NET MVC 4
body: <p>I have a basic form for which I want to handle buttons inside the form by calling the <code>ActionResult</code> method in the View's associated <code>Controller</code> class. Here is the following HTML5 code for the form:</p>
  
  <pre><code>&lt;h2&gt;Welcome&lt;/h2&gt;
  
  &lt;div&gt;
  
      &lt;h3&gt;Login&lt;/h3&gt;
  
      &lt;form method="post" action= &lt;!-- what goes here --&gt; &gt;
          Username: &lt;input type="text" name="username" /&gt; &lt;br /&gt;
          Password: &lt;input type="text" name="password" /&gt; &lt;br /&gt;
          &lt;input type="submit" value="Login"&gt;
          &lt;input type="submit" value="Create Account"/&gt;
      &lt;/form&gt;
  
  &lt;/div&gt;
  
  &lt;!-- more code ... --&gt;
  </code></pre>
  
  <p>The corresponding <code>Controller</code> code is the following:</p>
  
  <pre><code>[HttpPost]
  public ActionResult MyAction(string input, FormCollection collection)
  {
      switch (input)
      {
          case "Login":
              // do some stuff...
              break;
          case "Create Account"
              // do some other stuff...
              break;
      }
  
      return View();
  }
  </code></pre>