title: ASP MVC Friendly URL's and Relative Path Images
body: <p>I have an ASP.NET MVC page, where I am trying to show friendly URL's.</p>
  
  <p>So, I have a Category View in the Home Controller, that accepts a categoryKey value to get the content of the page.</p>
  
  <p>For instance: <a href="http://localhost/Home/Category/Bikes" rel="noreferrer">http://localhost/Home/Category/Bikes</a> gets the bike content.</p>
  
  <p>in my Global.asax.cs, i have the following to handle this:</p>
  
  <pre><code>public static void RegisterRoutes(RouteCollection routes)
  {
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  
    routes.MapRoute(
        "Category",
        "{controller}/{action}/{categoryKey}",
        new { controller = "Home", action = "Category", categoryKey = "" });
  
    routes.MapRoute(
        "Default", // Route name
        "{controller}/{action}/{id}", // URL with parameters
        new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
    );
  }
  </code></pre>
  
  <p>This works just fine, and it gets the content, however, I am getting the content from a Content Management system, for easy editing.  When you add an image on the content management, it adds the image with a relative path:</p>
  
  <pre><code>&lt;img src="../AdminUploadContent/bikes.gif" alt="Bikes" /&gt;
  </code></pre>
  
  <p>Now, if i goto "<a href="http://localhost/Home/Category" rel="noreferrer">http://localhost/Home/Category</a>", and that image tag is on the base page, it will pull up the image.  However, if i goto "<a href="http://localhost/Home/Category/" rel="noreferrer">http://localhost/Home/Category/</a>", or add the actual category of "/Home/Category/Bikes"/, the image doesn't show up.  The properties of the image is pointing to "<a href="http://localhost/Home/AdminUploadContent/bikes.gif" rel="noreferrer">http://localhost/Home/AdminUploadContent/bikes.gif</a>".</p>
  
  <p>Is there anything I can put in my Global.aspx.cs file to handle the relative path?  Even if i manually edit the content management to add ../../AdminUploadContent/bikes.gif, it is chopping off the first ../, since it is doing some validation.</p>