title: Passing variables with POST in ASP.NET MVC
body: <p>I am trying to pass a string variable inside asp.net MVC. I use breakpoints so I see that it does go to the correct method in the controller, but the variables posted are equal to null.</p>
  
  <p>My markup:</p>
  
  <pre><code>@{
      ViewBag.Title = "TestForm";
  }
  
  &lt;h2&gt;TestForm&lt;/h2&gt;
  
  @using (Html.BeginForm()) {
     &lt;input type="text" id="testinput" /&gt;
  
      &lt;input type="submit" value="TestForm" /&gt;
  }
  </code></pre>
  
  <p>My controller:</p>
  
  <pre><code>public ActionResult TestForm()
  {
      return View();
  } 
  
  [HttpPost]
  public ActionResult TestForm(string testinput)
  {
      Response.Write("[" + testinput + "]");
  
      return View();
  }
  </code></pre>
  
  <p>I put the breakpoint inside the second TestForm method and testinput is null....
  Am I missing something?</p>
  
  <p>Note: I realize that most of the time I will be using the model to pass data around, but I would like to know that I can pass strings as well.</p>
  
  <p>As part of the same question, how do I pass several variables? Would the method in my controller look like this:</p>
  
  <pre><code>[HttpPost]
  public ActionResult TestForm(string var1, var2)
  {
  }
  </code></pre>