title: MVC 4 creating slug type url
body: <p>i am trying to create a stackoverflow like url.</p>
  
  <p>I the following example works fine. But if i remove the controller then it errors out.</p>
  
  <pre><code>http://localhost:12719/Thread/Thread/500/slug-url-text
  </code></pre>
  
  <p>Note the first Thread is the controller the second is the action.</p>
  
  <p>How can i make the above URL look like the following excluding the controller name from the url?</p>
  
  <pre><code> http://localhost:12719/Thread/500/slug-url-text
  </code></pre>
  
  <p>My Routes</p>
  
  <pre><code>   public class RouteConfig
     {
      public static void RegisterRoutes(RouteCollection routes)
      {
          routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  
          routes.MapRoute("Default", // Route name
               "{controller}/{action}/{id}/{ignoreThisBit}",
               new
               {
                   controller = "Home",
                   action = "Index",
                   id = "",
                   ignoreThisBit = ""
               });  // Parameter defaults )
  
  
      }
   }
  </code></pre>
  
  <p>Thread Controller</p>
  
  <pre><code> public class ThreadController : Controller
   {
      //
      // GET: /Thread/
  
      public ActionResult Index()
      {
  
          string s = URLFriendly("slug-url-text");
          string url = "Thread/" + 500 + "/" + s;
          return RedirectPermanent(url);
  
      }
  
      public ActionResult Thread(int id, string slug)
      {
  
          return View("Index");
      }
  </code></pre>
  
  <p>}</p>