tags:

views:

39

answers:

1

I have an action link that looks like;

<%= Html.ActionLink(Model.forumItem.title, "ViewForumItem", new { Id = Model.forumItem.id, title=Model.forumItem.title.Replace(" ", "-") })%>

However the url it produces is;

http://localhost:50756/Home/ViewForumItem/System.Web.Mvc.UrlParameter/Clappy?Id=15

What can I do to make it look like;

http://localhost:50756/Home/ViewForumItem/15/Clappy

Much like SO does?

A: 

add a Route Definition like this

routes.MapRoute(
    "MyNewRoute", // Route name
    "Home/{action}/{id}/{title}", 
    new { controller = "Home", action = "Index", id = "", title = "" } // Parameter defaults
); 

make sure of your parameter keys in your ActionLink does exist in your Route Definition and in the same case since it is a case sensitive for example the id must have small case if you write it in small case in your Route Definition.

rob waminal