I'm trying to build URL in razor view that will pass 2 RouteData.Values to my action.
This is the code:
<input type="button" value="View" onclick="location.href='@Url.RouteUrl("ViewMessage", new { threadId = 955, messageId = 11 })'" />
In Global.asax I defined the following:
routes.MapRoute(
"ViewMessage", // Route name
"{controller}/{action}/{threadId}/{messageId}", // URL with parameters
new { controller = "Board", action = "Messages", threadId = UrlParameter.Optional, messageId = UrlParameter.Optional } // Parameter defaults
);
Why my url looks like this:
http://localhost/Site/Board/Messages/955?messageId=11
and not like this:
http://localhost/Site/Board/Messages/955/11
I understand that I can use string.Format, but rather to find MVC helper solution