title: How to hide controller name in Url?
body: <p>How to hide controller name in Url?</p>
  
  <p>I use the ASP.NET MVC.</p>
  
  <p>The original url is:  <a href="http://www.sample.com/Users.mvc/UserDetail/9615" rel="nofollow noreferrer">http://www.sample.com/Users.mvc/UserDetail/9615</a></p>
  
  <p>The "Users" is controller name, the "UserDetail" is action name, and the "9615" is UserId.</p>
  
  <p>How can I hide the controller name and action name in the url. </p>
  
  <p>Just like this: <a href="http://www.sample.com/9615" rel="nofollow noreferrer">http://www.sample.com/9615</a></p>
  
  <p>I have writed the following code in the Global.ascx.cs to hide the action name:</p>
  
  <pre><code>routes.MapRoute(
               "UserDetail",             // Route name
               "Users.mvc/{UserId}",              // URL with parameters
               new { controller = "Users", action = "UserDetail", UserId = "" }  // Parameter defaults
              );
  </code></pre>
  
  <p>Using the above code I hid the action name and got this url: <a href="http://www.sample.com/Users.mvc/9615" rel="nofollow noreferrer">http://www.sample.com/Users.mvc/9615</a></p>
  
  <p>But how can I hide the controller name and get this url:  <a href="http://www.sample.com/9615" rel="nofollow noreferrer">http://www.sample.com/9615</a></p>
  
  <p>Thanks.</p>