title: ASP.NET MVC Html.BeginForm Problem
body: <p>I have a partial view:</p>
  
  <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;DomainModel.Entities.Product&gt;" %&gt;
  
  &lt;div class="item"&gt;
      &lt;h3&gt;&lt;%= Model.Name %&gt;&lt;/h3&gt;
      &lt;%= Model.Description %&gt;
  
      &lt;% using (Html.BeginForm("AddToCart", "Cart")) { %&gt;
          &lt;%= Html.Hidden("ProductID") %&gt;
          &lt;%= Html.Hidden("returnUrl", ViewContext.HttpContext.Request.Url.PathAndQuery) %&gt;
          &lt;input type="submit" value="+ Add to cart" /&gt;
      &lt;% } %&gt;
  
      &lt;h4&gt;&lt;%= Model.Price.ToString("c")%&gt;&lt;/h4&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And here is the html that gets rendered:</p>
  
  <pre><code>&lt;div class="item"&gt; 
      &lt;h3&gt;Kayak&lt;/h3&gt; 
      A boat for one person
      &lt;form action="" method="post"&gt;
          &lt;input id="ProductID" name="ProductID" type="hidden" value="1" /&gt; 
          &lt;input id="returnUrl" name="returnUrl" type="hidden" value="/" /&gt; 
          &lt;input type="submit" value="+ Add to cart" /&gt; 
      &lt;/form&gt; 
      &lt;h4&gt;$275.00&lt;/h4&gt; 
  &lt;/div&gt; 
  </code></pre>
  
  <p>Nothing happens when the submit button is clicked and I am pretty sure it's because the form action attribute has no value. Shouldn't BeginForm(action, controller) take care of rendering out the form action? What am I doing wrong?</p>
  
  <h2>EDIT</h2>
  
  <p>Code from CartController AddToCart action:</p>
  
  <pre><code>    public RedirectToRouteResult AddToCart(Cart cart, int productID, string returnUrl)
      {
          Product product = productsRepository.Products.FirstOrDefault(p =&gt; p.ProductID == productID);
  
          cart.AddItem(product, 1);
          return RedirectToAction("Index", new { returnUrl });
      }
  </code></pre>
  
  <h2>EDIT 2</h2>
  
  <p>The view that renders the partial:</p>
  
  <pre><code>&lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"&gt;
      &lt;% foreach (var product in Model) { %&gt;
          &lt;% Html.RenderPartial("ProductSummary", product); %&gt;
      &lt;% } %&gt;
  
      &lt;div class="pager"&gt;
      Page:
      &lt;%=Html.PageLinks((int)ViewData["CurrentPage"],
                        (int)ViewData["TotalPages"],
                        x =&gt; Url.Action("List", new { page = x, category = ViewData["CurrentCategory"] })) %&gt;
      &lt;/div&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <h2>EDIT 3</h2>
  
  <p>Routes:</p>
  
  <pre><code>public static void RegisterRoutes(RouteCollection routes)
      {
          routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  
          routes.MapRoute(
              null, // don't need a name
              "", // matches the root URL, i.e. ~/
              new { controller = "Products", action = "List", category = (string)null, page = 1 } //Defaults
          );
  
          routes.MapRoute(
              null, // don't need name
              "Page{page}", // URL pattern, e.g. ~/Page683
              new { controller = "Products", action = "List", category = (string)null }, // defaults
              new { page = @"\d+" } // constraints: page must be numerical
          );
  
          routes.MapRoute(null,
              "{category}",
              new { controller = "Products", action = "List", page = 1 });
  
          routes.MapRoute(null,
              "{category}/Page{page}",
              new { controller = "Products", action = "List" },
              new { page = @"\d+" } // constraints: page must be numerical
          );
  
      }
  </code></pre>