I am using RegisterRoutes method in Global file to route user url to actual url.
routes.MapRoute("Blog",
"blog/dp/{id}",
new { controller ="Blog", action = "Details" });
As you might have guessed, Blog is the controller and Details is its action.
So the problem is that the following code does not generate my desire URL which has dp word in its url.
By the way, I don’t want to change my Action Name.
@Html.ActionLink( "headline", "Details", "Blog", new { id="1200" }, null )
Thanks in advance 😉
You could use a RouteLink instead of using an ActionLink. In a RouteLink you can explicitly pass your route name:
More about RouteLink method can be found in the MSDN. Reordering routes can do the job but that’s a rather fragile mechanism.