title: Pagination not working correctly in ASP.NET MVC 5
body: <p>I have a page that enables user to filter results using various filters. When I use a filter (for example writer), I get pagination as well. But when I click page 2, pagination works like there is no filter. How can I fix it? Thanks. Here's my view : </p>
  
  <pre><code>@using (Html.BeginForm("Reporting", "Book",FormMethod.Get))
  {
      &lt;p&gt;
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Publication Name : @Html.TextBox("nameSearch", ViewBag.CurrentFilter as string)
                      &lt;input type="submit" value="Search in names" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr style ="background-color:white"&gt;
                  &lt;td&gt;
                      Writer : @Html.TextBox("writerSearch", ViewBag.CurrentFilter as string)
                      &lt;input type="submit" value="Search in writers" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr style="background-color:white"&gt;
                  &lt;td&gt;
                      Publication No : @Html.TextBox("publicationNoSearch", ViewBag.CurrentFilter as string)
                      &lt;input type="submit" value="Search in publication no" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr style="background-color:white"&gt;
                  &lt;td&gt;
                      Is On Sale : @Html.DropDownList("isOnSale", new List&lt;SelectListItem&gt;
                                       {
                                           new SelectListItem {Text = "", Value=null},
                                           new SelectListItem {Text = "Yes", Value="Yes"},
                                           new SelectListItem {Text = "No", Value="No"},
  
                                       }, ViewBag.CurrentFilter as string)
                      &lt;input type="submit" value="List" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
  
          &lt;/table&gt;
  
      &lt;/p&gt;
  }
  
  &lt;table style="border : 1px solid black;"&gt;
      &lt;tr style="border : 1px solid black;"&gt;
          &lt;th style="border : 1px solid black;"&gt;
              Publication No
          &lt;/th&gt;
          &lt;th style="border : 1px solid black;"&gt;
          Writer
          &lt;/th&gt;
          &lt;th style="border : 1px solid black;"&gt;
  
              Publication Name
  
          &lt;/th&gt;
  
      &lt;/tr&gt;
  
  @foreach (var item in Model)
  {
  
  
      &lt;tr style="border : 1px solid black;"&gt;
          &lt;td style="border : 1px solid black;" width="100"&gt;
              @Html.DisplayFor(modelItem =&gt; item.PublicationNo)
          &lt;/td&gt;
          &lt;td style="border : 1px solid black;" width="290"&gt;
              @if (item.Yazari != null)
              {
                  @Html.DisplayFor(modelItem =&gt; item.Writer)
              }
          &lt;/td&gt;
  
          &lt;td style="border: 1px solid black; font-style: italic;" width="360"&gt;
              @Html.DisplayFor(modelItem =&gt; item.PublicationName)
          &lt;/td&gt;
  &lt;/table&gt;
  
  &lt;br/&gt;
  
  Page :  @(Model.PageCount &lt; Model.PageNumber ? 0 : Model.PageNumber) / @Model.PageCount
  
  &lt;div class="yui3-cssreset"&gt;
      @Html.PagedListPager(Model, page =&gt; Url.Action("Reporting",
      new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }))
  &lt;/div&gt;
  </code></pre>
  
  <p>And this is my controller : </p>
  
  <pre><code>public ActionResult Reporting(string nameSearch, string writerSearch, string publicationNoSearch,string isOnSale , string CurrentFilter, int? page)
  {
  
      if (nameSearch != null)
      {
          page = 1;
      }
      else
      {
          nameSearch = CurrentFilter;
      }
  
      ViewBag.CurrentFilter = nameSearch;
  
      var books = from b in db.Book select b;
  
  
      if (!String.IsNullOrEmpty(isimSearch))
      {
          books = books.Where(b =&gt; b.PublicationName.Contains(nameSearch));
      }
      else if (!String.IsNullOrEmpty(writerSearch))
      {
          books = books.Where(b =&gt; b.Writer.Contains(writerSearch));
      }
      else if (!String.IsNullOrEmpty(publicationNoSearch))
      {
          int publicationNoForSearch;
          publicationNoForSearch = Int32.Parse(publicationNoSearch);
          books = books.Where(b =&gt; b.PublicationNo == publicationNoForSearch);
      }
      else if (isOnSale == "Yes")
      {
          books = books.Where(b =&gt; b.isOnSale == true);
      }
      else if (isOnSale == "No")
      {
          books = books.Where(b =&gt; b.isOnSale == false);
      }
      else
      {
          ;
      }
  
      books = books.OrderBy(b =&gt; b.PublicationNo);
      int pageSize = 50;
      int pageNumber = (sayfa ?? 1);
  
      return View(books.ToPagedList(pageNumber, pageSize));
  }
  </code></pre>