title: Getting HTML form data to ASP.NET controller
body: <p>So I have a view containing a HTML login form and I need to get the values from the form to a controller via post. Right now I'm trying to display the username of the user through the Content method when the form is submitted, once I know I have the username in the controller I can do the rest. The problem I have is that when I submit the form the username is not displayed, I've outputted to the console to check if the controller action is being called and it isn't.</p>
  
  <p>Any help is greatly appreciated cheers!</p>
  
  <p><strong>View</strong></p>
  
  <pre><code>@{
      @model AdminPanel.Models.cUser
      Layout = null;
      ViewBag.Title = "Login";
  }
  
  &lt;head&gt;
      &lt;link href="~/Content/Login.css" rel="stylesheet" type="text/css" /&gt;
      &lt;link href="~/Content/Site.css" rel="stylesheet" type="text/css" /&gt;
      &lt;link href="~/Content/bootstrap.min.css" rel="stylesheet" type="text/css" /&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;!-- Div containing the log in box parent --&gt;
      &lt;div class="log-in-box-parent"&gt;
          &lt;h2&gt;LOG IN&lt;/h2&gt;
  
          &lt;div class="log-in-form"&gt;
              &lt;form asp-action="Login" asp-controller="Login"&gt;
                  &lt;input asp-for="Username" type="text" id="Username" placeholder="Username" /&gt; &lt;br /&gt;
                  &lt;input aso-for="Password" type="password" id="Password" placeholder="Password" /&gt; &lt;br /&gt;
                  &lt;input type="submit" id="login" value="Log in"/&gt;
              &lt;/form&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>using AdminPanel.Models;
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  
  namespace AdminPanel.Controllers
  {
      public class LoginController : Controller
      {
          // GET: Login
          public ActionResult Index()
          {
              return View();
          }
  
          [HttpPost, ValidateAntiForgeryToken]
          public ActionResult Login(cUser user)
          {
              return Content($"Hello {user.Username}");
          }
      }
  }
  </code></pre>
  
  <p>And finally my user model</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  
  namespace AdminPanel.Models
  {
      public class cUser
      {
          public string Username { get; set; }
          public string Password { get; set; }
      }
  }
  </code></pre>