title: Binding submit button in view to action result method in Controller
body: <p>I'm relatively new to ASP.NET and MVC (I normally work in winforms/wpf) and i'm trying to teach myself the basics. I am trying to create a simple to-do list style thing where you enter a line of text into a textbox click the add button and that populates a list underneath.</p>
  
  <p>Here is my view (Index.cshtml) which sits in the Views>ToDo folder:</p>
  
  <pre><code>@{
  ViewBag.Title = "Index";
  }
  @model List&lt;Models.ToDoListItem&gt;
  &lt;h2&gt;To Do List&lt;/h2&gt;
  
  &lt;form asp-action="Create" asp-controller="ToDo" asp-method="post"&gt;
      &lt;div&gt;
          &lt;input name="ToDoItem"/&gt;
          &lt;input type="submit" value="Add Task"/&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  
  &lt;div&gt;
      &lt;ul&gt;
          @if (Model != null)
          {
              foreach (var item in Model)
              {
                  &lt;li&gt;
                      &lt;label&gt;@item.ItemText&lt;/label&gt;
                  &lt;/li&gt;
              }
          }
  
      &lt;/ul&gt;
  &lt;/div&gt; 
  </code></pre>
  
  <p>And here is my Controller <code>ToDoController.cs</code> which sits in the Controllers folder</p>
  
  <pre><code>public class ToDoController : Controller
  {
      // GET: ToDo
      public ActionResult Index()
      {
          return View(Models.ToDoListItem.GetAll());
      }
  
      [HttpPost] //This was added as suggested in comments and answers
      public ActionResult Create(string toDoItem)
      {
          Models.ToDoListItem.Create(toDoItem);
          return RedirectToAction("Index");
      }
  }
  </code></pre>
  
  <p>Now from what I have read, adding the action <code>Create</code>  to  the <code>ToDocontroller</code>  part to my form tag should map my submit button click to the "Create" <code>ActionResult</code> method in my <code>ToDoController</code> class.</p>
  
  <p>When I run my code with a break-point on the create method, clicking the submit button doesn't hit the break-point and nothing gets added to the list. </p>
  
  <p>If anyone has any idea where I went wrong, some assistance would be much appreciated. </p>
  
  <p>Thanks.</p>