title: Routing by slug in asp.net mvc
body: <p>I have a controller action as you can see below: </p>
  
  <pre><code>public ActionResult Content(string slug)
  {
      var content = contentRepository.GetBySlug(slug);
  
      return View(content);
  }
  </code></pre>
  
  <p>I want this kind of urls to be routed to my action:</p>
  
  <blockquote>
    <p><a href="http://localhost/slug-of-my-content" rel="nofollow">http://localhost/slug-of-my-content</a></p>
  </blockquote>
  
  <p>Here is my RegisterRoutes method:</p>
  
  <pre><code>    public static void RegisterRoutes(RouteCollection routes)
      {
          routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  
          routes.MapRoute(
              name: "Default",
              url: "{controller}/{action}/{id}",
              defaults: new { controller = "Page", action = "Index", id = UrlParameter.Optional }
          );
  
          routes.MapRoute(
             name: "GetContent",
             url: "{slug}",
             defaults: new { controller = "Page", action = "Content", slug = "" }
             );
      }
  </code></pre>
  
  <p>But it does not work, what am I doing wrong?</p>
  
  <p>Thanks,</p>