title: Can I use a @Html.PagedListPage with a @url.Action post
body: <p>What I am trying to do is I have an input box, that serves as a "Search string", it is a POST to the Search Action, on the same screen I would like to display the results, and this works great, with one exception, when I try to employ the Pageing controls, "@html.PagedList. That Control is constantly going back to the the "[httpGet] Search not the post.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>public ActionResult Search()
      {
          return View();
      }
  
  [HttpPost]
  public ActionResult Search(FormCollection fc, int? pageNumber)
  {
      var searchString = fc["searchString"];
      var results = new ArrayList();
      var mylist = new List&lt;SearchResult&gt;();
      var model = new SearchViewModel();
  
      // Search Communities
      var search = from s in db.Communities
                   where s.ComunityName.Contains(searchString) || s.Description.Contains(searchString)
                   select s;
  
      // Search Resource Center
      var docs = from d in db.ResourceCenters
                 where d.Title.Contains(searchString) || d.Description.Contains(searchString)
                 select d;
  
      // Set up Arraylist with type Community
      foreach(var c in search)
      {
          var community = new SearchResult();
          community.type = "community";
          community.CommunityId = c.CommunityId;
          community.CommunityName = c.ComunityName;
          community.Description = c.Description;
          community.CommunityType = c.CommunityType1.TypeName;
          community.CommunityCity = c.CommunityCity;
          community.CommunityState = c.CommunityState;
          community.CommunityZip = c.CommunityZip;
          community.Population = c.Population;
          mylist.Add(community);
      }
  
      // Set up ArrayList with type ResourceCenter
      foreach (var d in docs)
      {
          var document = new SearchResult();
          document.type = "document";
          document.Title = d.Title;
          document.Document_Description = d.Description;
          document.FilePath = d.FilePath;
          document.Date = Convert.ToDateTime(d.Date);
          document.UpLoadedBy = d.UpLoadedBy;
          mylist.Add(document);
      }
  
      model.results = mylist;
      ViewBag.results = model.results;
      ViewBag.searchString = searchString;
  
      return View(mylist.ToPagedList(pageNumber ?? 1, 5));
  </code></pre>
  
  <p>and the markup:</p>
  
  <pre><code>@using (Html.BeginForm("Search", "Home", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
  {
      &lt;input type="text" id="searchString" name="searchString" class="form-control" required="required" /&gt;
      &lt;input type="submit" class="btn btn-default" value="Search" /&gt;
      &lt;hr /&gt;
  
  
      if (@Model != null)
      {
          if (@Model.Count != 0)
          {
              &lt;h3&gt;The following results were found for @ViewBag.searchString&lt;/h3&gt;
  
  
              foreach (var search in @Model)
              {
  
                  if (@search.type == "community")
                  {
                      &lt;div class="resource-element"&gt;
                          &lt;a href="/Communities/CommunityPage/@search.CommunityId"&gt;
                              &lt;span class="resource-type pull-right"&gt;Community&lt;/span&gt;
                          &lt;/a&gt;
                          &lt;a href="/Communities/CommunityPage/@search.CommunityId"&gt;&lt;h3&gt;@search.CommunityName&lt;/h3&gt;&lt;/a&gt;
                          &lt;p&gt;@search.Description&lt;/p&gt;
                          &lt;span class=""&gt;Type : @search.CommunityType&lt;/span&gt;&lt;br /&gt;
                          &lt;span class=""&gt;@search.CommunityCity, @search.CommunityState @search.CommunityZip&lt;/span&gt;&lt;br /&gt;
                          &lt;span class=""&gt;Population: @search.Population&lt;/span&gt;
                          &lt;br&gt;
                      &lt;/div&gt;
                  }
                  else
                  {
  
  
                      &lt;div class="resource-element"&gt;
                          &lt;a href="@search.FilePath"&gt;
                              &lt;span class="resource-type pull-right"&gt;Document&lt;/span&gt;
                          &lt;/a&gt;
                          &lt;a href="@search.FilePath"&gt;&lt;h3&gt;@search.Title&lt;/h3&gt;&lt;/a&gt;
                          &lt;p&gt;@search.Document_Description&lt;/p&gt;
                          &lt;span class=""&gt;@search.Date&lt;/span&gt;
                          &lt;br&gt;
                          &lt;span class=""&gt;@search.UpLoadedBy&lt;/span&gt;
                          &lt;br&gt;
                      &lt;/div&gt;
                  }
  
              }
  
              @Html.PagedListPager(Model, pageNumber =&gt; Url.Action("Search", "Home", new { pageNumber }),
              new PagedListRenderOptions() { Display = PagedListDisplayMode.IfNeeded, DisplayPageCountAndCurrentLocation = true })
  
          }
          else
          {
  
              if (@Model.Count == 0)
              {
                  &lt;div class="resource-element"&gt;
                      &lt;a href="#"&gt;
                          &lt;span class="resource-type pull-right"&gt;&lt;/span&gt;
                      &lt;/a&gt;
                      &lt;h3&gt;No Results Found&lt;/h3&gt;
                  &lt;/div&gt;
  
              }
  
  
          }
      }
  
  }
  </code></pre>