Mvc route actionlink name of the used URL instead of id

I think I already asked about this, but the solution really didn't make sense. Anyway, I have ActionLinks on my views like this:

foreach( var item in Model){
<%: Html.ActionLink(item.Name, "Details", new {id = item.Id}) %>
}

now when it goes to my action data obviously this will be the url

/MyThings/Details/{id}

I was wondering if it is possible to show the name of this element instead of the bullet usage identifier? or changing global asax like this:

/MyThings/Details/CarKeys

The thing in the names must be unique, is there a way to change the global asax to show the name instead of id?

Any advice is greatly appreciated!

+5
source share
2 answers

, . Global.asax.cs , :

routes.MapRoute(..., "{controller}/{action}/{id}", ...);

... - :

routes.MapRoute(..., "{controller}/{action}/{name}", ...);

ID:

Html.ActionLink(item.Name, "Details", new {item.Name})
+6

SEO, . URL-, . , : {controller}/{action}/{id}/{name}

, , URL-. , . : http://chrismckee.co.uk/creating-url-slugs-permalinks-in-csharp/

+8

All Articles