Can anyone help me? I'm doing some tests in ASP.NET MVC.
I want to implement the nice URL as stackoverflow.com routing system.
For example: stackoverflow.com/questions/1074/asp-mvc domain.com/id/title
Here is my code:
in the Global.asax
routes.MapRoute(null, "posts/{PostId}/{Title}", new { controller = "Posts", action = "Details", post = (string)null }, new { PostId = @"\d+", Title = @"([A-Za-z0-9-]+)" } );
in the View:
<%= Html.ActionLink(Model.Title, "Details", new { Model.PostID, Model.Title})%>
With those codes, I am geting the url : http://localhost:53171/posts/Details?PostID=5&Title=Test-title
Can one one advise me?
Thank you very much.