title: How to redirect a POST request to a url maintaining model values in MVC
body: <p>I have a fairly standard sort/filter/page search form but need control over the format of the url. The sort/filter/page parameters should all be part of the url so that, for example, the address could be emailed to someone.</p>
  
  <p>When another filter parameter is added, a POST request is made. My controller method looks like this:</p>
  
  <pre><code>[HttpPost]
  public ActionResult Search(string filterField,
                             Operator filterOperator, 
                             string filterValue, 
                             PeopleGroupSearchModel model);
  </code></pre>
  
  <p>The <code>PeopleGroupSearchModel</code> is populated from query string parameters. The <code>filter*</code> parameters are coming from the posted form values.</p>
  
  <p>I would like to parse the provided filter values, which will then add a filter to a collection in the model called <code>Filters</code>. Then, take the updated model and convert it to the appropriate url and pass that as the response to the user.</p>
  
  <p>So, for example, if they are on this page:</p>
  
  <pre><code>PeopleGroup/Search?page=4&amp;sort=Country
  </code></pre>
  
  <p>... and POST:</p>
  
  <ul>
  <li>filterField = PeopleGroupName</li>
  <li>filterOperator = Equals</li>
  <li>filterValue = Zulu</li>
  </ul>
  
  <p>... once all the processing is done, the address in their browser should be something like:</p>
  
  <pre><code>PeopleGroup/Search?page=4&amp;sort=Country&amp;PeopleGroupName=Zulu&amp;PeopleGroupName_op=Equals
  </code></pre>
  
  <p>So, more or less what I am trying to do:</p>
  
  <pre><code>[HttpGet]
  public ActionResult Search(PeopleGroupSearchModel model)
  {
      PeopleGroupData.Search(model);
      ViewData.Model = model;
      return View();
  }
  
  [HttpPost]
  public ActionResult Search(string filterField,
                             Operator filterOperator,
                             string filterValue,
                             PeopleGroupSearchModel model)
  {
      PeopleGroupFilter filter = ParseFilter(filterField, 
                                             filterOperator, 
                                             filterValue);
      model.Filters.Add(filter);
      return RedirectToAction("Search", ???);
  }
  </code></pre>
  
  <p>I am <em>very</em> new to MVC, so if I am going about this completely the wrong way, please let me know!</p>