title: Shortening URL params with MVC routing
body: <p>I have a url along the lines of this:</p>
  
  <blockquote>
    <p>example.com/profile/publicview?profileKey=5</p>
  </blockquote>
  
  <p>and I want to shorten it to this with routing</p>
  
  <blockquote>
    <p>example.com/profile/5</p>
  </blockquote>
  
  <p>How do I do this?</p>
  
  <p>This is my attempt:</p>
  
  <pre><code>routes.MapRoute(
      "Profile", "Profile/{profileKey}", 
      new { controller = "Profile", action = "PublicView", profileKey ="" }
  );
  </code></pre>
  
  <p>But his produces this error:</p>
  
  <blockquote>
    <p>The parameters dictionary contains a
    null entry for parameter 'profileKey'
    of non-nullable type 'System.Int32'
    for method
    'System.Web.Mvc.ActionResult
    PublicView(Int32)' in
    'Website.Controllers.ProfileController</p>
  </blockquote>
  
  <p>Action method</p>
  
  <pre><code>public ActionResult PublicView(int profileKey)
    {
          //stuff
    }
  </code></pre>