title: ASP.NET Mvc 5 return View with seo friendly url
body: <p>I'm looking for a way to return a View based on an Id, but adding a friendly url part when returning.</p>
  
  <p>I know I can pass in the id and name when I have this data available, e.g. by using:</p>
  
  <pre><code>Url.Action("Index", "Cat", new { id = model.ID, seoname = model.SEO });
  
  
  [AllowAnonymous]
  [Route("Cat/{id?}/{seoname?}")]
  public ActionResult Index(int? id = null, string seoname = null) {
     // do something with id and create viewmodel 
  
     // in case I get redirect from the SelCat actionresult:
     if (id.HasValue and string.IsNullOrEmpty(seoname)) { 
        // look in the database for title by the given id
        string seofriendlyTitle = ...;
        RouteData.Values.AddOrSet("seoname", seofriendlyTitle);
     }
  
     return View(viewmodel);
  }
  </code></pre>
  
  <p>this code above is not a problem. The problem occurs when I submit a form (dropdownlist) where I only have the Id available.</p>
  
  <pre><code>[HttpPost]
  [AllowAnonymous]
  [Route("Cat/SelCat/{form?}")]
  public ActionResult SelCat(FormCollection form) 
  { 
     string selectedValues = form["SelectedCat"];
     // ...
     int id = selectedCatID;
     return RedirectToAction("Index", new { id = id });
  } 
  </code></pre>
  
  <p>In case I redirect from the SelCat action to the Index action with only an ID I want to search the seofriendly name and when returning the view. I was hoping that the url had the friendly url part.</p>
  
  <pre><code>   // in case I get redirect from the SelCat actionresult:
     if (id.HasValue and string.IsNullOrEmpty(seoname)) { 
        // look in the database for title by the given id
        string seofriendlyTitle = ...;
        RouteData.Values.AddOrSet("seoname", seofriendlyTitle); // &lt;-- does not alter url
     }
  </code></pre>
  
  <p><strong>How can I make my url seo friendly when returning a View in my Controller Action when only an ID is given?</strong> 
  <strong>Setting the RouteData.Values. does not seem to add the part to the url.</strong></p>