title: ASP.NET MVC3: 2 forms on page, submit triggers the wrong one
body: <p>I have 2 forms on the same page. One is a form in a partial view which is rendered via a child action we'll call this PodForm. The second is rendered by the current action.</p>
  
  <p>So my code looks a little like this (please ignore names etc, this is example code):</p>
  
  <p>Form.cshtml</p>
  
  <pre><code>@model MyProject.Models.FormInputModel
  @using(Html.BeginForm("Form","Main",FormMethod.Post))
  {
    @Html.TextBoxFor(x=&gt;x.AField)
    @* Some other fields *@
    &lt;input type="submit"/&gt;
  }
  
  &lt;div class="sidebar"&gt;
     @Html.Action("PodForm","Pod")
  &lt;/div&gt;
  </code></pre>
  
  <p>PodForm.cshtml</p>
  
  <pre><code>@model MyProject.Models.PodFormInputModel
  @using(Html.BeginForm("PodForm","Pod",FormMethod.Post))
  {
    @Html.TextBoxFor(x=&gt;x.Name)
    @* Some other fields *@
    &lt;input type="submit"/&gt;
  }
  </code></pre>
  
  <p>When I click submit on the Main form, the PodForm action method is triggered. What's going on?</p>
  
  <p><strong>Edit - As requested in the comments</strong>:</p>
  
  <ol>
  <li><p>The generated mark up looks similar to the following.</p>
  
  <pre><code>&lt;form action="/Main/Form" encoding="multipart/form-data" method="POST"&gt;
       &lt;input type="text" name="AField" /&gt;
       &lt;input type="submit" /&gt;
    &lt;/form&gt;
  
   &lt;div class="sidebar"&gt;
     &lt;form action="/Pod/PodForm" method="POST"&gt;
         &lt;input type="text" name="Name" /&gt;
         &lt;input type="submit" /&gt;
     &lt;/form&gt;
   &lt;/div&gt;
  </code></pre></li>
  <li><p>Controller actions</p>
  
  <p>The "MainController" (not the actual name) has an action called "Form"</p>
  
  <pre><code>public MainController : Controller
  {
      public ActionResult Form()
      {
          return View();
      }
  
      [HttpPost]
      public ActionResult Form()
      {
          if(ModelState.IsValid)
          {
            //Save
          }
  
          return View();
      }
  }
  </code></pre>
  
  <p>The "PodController" (not the actual name) has an action called "PodForm". The Reason the HttpPost does not return View is that doing that from a child action returns just the partial view - not what I want.</p>
  
  <pre><code>    public PodController : Controller
      {
         public ActionResult PodForm()
         {
            return View();
         }
  
         [HttpPost]
         public ActionResult PodForm(PodFormInputModel model)
         {
            if(ModelState.IsValid)
            {
               //Save the thing   
  
                return RedirectToAction(Request.HttpReferrer.ToString()).AndFlash("Saved");
            }
  
            return RedirectToAction(Request.HttpReferrer.ToString()).AndFlash("Not saved");
         }
      }
  </code></pre></li>
  </ol>
  
  <p><strong>UPDATE: I have figured out that the first action method <em>is</em> called but because it returns a View() the view engine is calling the PodForm action method as a Post rather than as a Get which is triggering the submit logic. Weird.</strong></p>