I'm working on an ASP.NET MVC 3 app and it works fine when using the default routes. So I have urls similar to this, localhost:4457/Users/Details/5
I want to add a friendly slug to the url to make it localhost:4457/Users/Details/5/some-ones-name.
So I added a custom route and my routes now look like so
routes.MapRoute(
"withslug",
"{controller}/{action}/{id}/{slug}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional, slug = UrlParameter.Optional });
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional });
On the view I have an action link like this
@Html.ActionLink(Model.Name,"Details","Users", new { id=Model.ID, slug="some-ones-name"},null)
I also have image links like this
<img src="../../Content/images/picture.jpg" alt="" height="42" width="37" />
The link works okay and when I click it follows correctly. The address reads localhost:4457/Users/Details/5/some-ones-name. The problem is all the images on the page are now broken and my javascript functions won't run.
If I remove the slug from the address and just leave the url as localhost:4457/Users/Details/5 everything works as expected.
If I add even a slash after the id, everything breaks again. The content loads as expected though, just the images and some javascript functions.
I don't understand what the problem is and any insight will be highly appreciated.