title: ASP.NET MVC 5 Partial View with Ajax form
body: <p>I am attempting to create a search form with a partial view. Currently I have the two partial views rendering properly and search functionality is working. The part I am having difficulty with is updating the list of items with the content returned from the action controller method.</p>
  
  <p>The view that is rendering the partials.</p>
  
  <pre><code>&lt;div&gt;
  &lt;hr /&gt;
      @if(Model.Count == 0)
      {
          &lt;h2&gt;No existing announcements.&lt;/h2&gt;
      }
      else
      {
  
          @Html.Action("Search", "Announcements")
          { Html.RenderPartial("_SearchResults", Model); }
      }
  &lt;/div&gt;
  </code></pre>
  
  <p>The search partial view</p>
  
  <pre><code>@using (Ajax.BeginForm("Search", "Announcements", null, new AjaxOptions { InsertionMode = InsertionMode.Replace, HttpMethod = "POST", UpdateTargetId = "search-results" }, new { id = "search-form" }))
  {
  &lt;div class="container"&gt;
  
      &lt;!-- Begin Search Box --&gt;
      &lt;div class="row"&gt;
          &lt;div id="col-lg-12"&gt;
              &lt;div class="input-group col-lg-8 col-lg-offset-1"&gt;
                  &lt;div class="input-group-btn"&gt;
                      &lt;button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"&gt;
                          Filter By Categories&amp;nbsp;&lt;span class="caret"&gt;&lt;/span&gt;
                      &lt;/button&gt;
                      &lt;ul class="dropdown-menu" id="categoryMenu"&gt;
                          @for (int i = 0; i &lt; Model.Count; i++)
                          {
                              &lt;li&gt;
                                  &lt;a href="#" data-value="@Model[i].IsSelected" class="small" tabindex="-1"&gt;
                                      @Html.CheckBoxFor(model =&gt; Model[i].IsSelected) @Model[i].Name&lt;text&gt;&amp;nbsp;&lt;/text&gt;
                                  &lt;/a&gt;
                                  @Html.HiddenFor(model =&gt; Model[i].ID)
                                  @Html.HiddenFor(model =&gt; Model[i].Name)
                              &lt;/li&gt;
                          }
                          &lt;li&gt;
                              &lt;hr /&gt;
                              &lt;button type="button" class="btn btn-sm btn-danger pull-right" style="margin-right:5px;" id="btn-clear"&gt;Clear&lt;/button&gt;
                          &lt;/li&gt;
                      &lt;/ul&gt;
                  &lt;/div&gt;
                  @Html.TextBox("query", null, htmlAttributes: new { @class = "search-box form-control", type = "text", placeholder = "Search Announcements", id="query" })
                  &lt;div class="input-group-btn"&gt;
                      &lt;button class="btn btn-primary" type="submit"&gt;
                          &lt;span class="glyphicon glyphicon-search"&gt;&lt;/span&gt;
                      &lt;/button&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;!-- End Search Box --&gt;
      &lt;div class="row"&gt;
          &lt;div class="pull-left col-lg-offset-1 form-inline"&gt;
              &lt;a href="#" id="date-search" style="text-decoration: none;"&gt;
                  &lt;span class="glyphicon glyphicon-plus-sign"&gt;&lt;/span&gt; Narrow By Date
              &lt;/a&gt;
          &lt;/div&gt;
          &lt;div class="col-lg-8 col-lg-offset-2" id="date-boxes"&gt;
              &lt;div class="col-lg-4"&gt;
                  Start: @Html.TextBox("start", null, htmlAttributes: new { type = "date", id = "startDate" })
              &lt;/div&gt;
              &lt;div class="col-lg-4"&gt;
                  End: @Html.TextBox("end", null, htmlAttributes: new { type = "date", id = "endDate" })
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  }
  </code></pre>
  
  <p>And the controller action method that is doing the dirty work</p>
  
  <pre><code>[HttpGet]
  public PartialViewResult Search()
  {
      List&lt;CategoryViewModel&gt; model = new List&lt;CategoryViewModel&gt;();
      ... Some codes ...
      return PartialView("_SearchForm", model);
  }
  
  [HttpPost]
  public PartialViewResult Search(List&lt;CategoryViewModel&gt; cvm, DateTime? start, DateTime? end, string query = "")
  {
      List&lt;EditViewModel&gt; model = new List&lt;EditViewModel&gt;();
  
      ... Bunch of extranneous code ...
  
      return PartialView("_SearchResults", model);
  }
  </code></pre>
  
  <p>I simply want to use a partial view to render the results of the search, but when I submit the search form, I get redirected to "...path.../Search" instead of "...path.../Manage" where it should return. Any help on how to do this properly would be greatly appreciated.</p>