title: asp.net mvc - Rewrite Url after return view
body: <p>I have a problem like this. In RouteConfig.cs, I set routes </p>
  
  <pre><code>routes.MapRoute(
        "NewsDetails",
        "news/details-news/{title}-{id}",
        new { controller = "News", action = "Details", id = "", title = "" }
  );
  </code></pre>
  
  <p>In my Index.cshtml of NewsController I have a link</p>
  
  <pre><code>@Html.RouteLink(item.Title, "NewsDetails", new { 
           title = MyWeb.Classes.PrettyUrlHelper.PrettyUrl(item.Title), 
           id = item.Id 
  })
  </code></pre>
  
  <p>In my NewsController:</p>
  
  <pre><code>public ActionResult Details(string title,String id)
  {
      if (id == null &amp;&amp; title == null)
         return RedirectToAction("Index");
  
  
       try
       {
          int ID = Int32.Parse(id);
  
          var result = NewsConnectionDB.GetInstance().Single&lt;LifeStory&gt;(ID);
  
          return View(result);
        }
  
        catch (InvalidOperationException) { 
            return  View("~/Views/Error/Error404.cshtml"); 
        }
        catch (FormatException) { 
            return View("~/Views/Error/Error404.cshtml"); }
   }
  </code></pre>
  
  <p>So if a user click on link in View, that link will route to action Details to process, and the link is Seo Url Friendly (localhost:9224/news/details-news/ten-things-2). But a user types a link instead of clicking to a link in View:</p>
  
  <pre><code>  localhost:9224/news/details-news/ten-thingsblahblahblah-2
  </code></pre>
  
  <p>The url above is correct with id but title is not. So how can I update the url after I return View if a user types the wrong title but right id? </p>
  
  <p>Any help would be appreciated.</p>
  
  <p>P/S: my English is not good, so I hope you understand it.</p>