How do I use Asp MVC Url Helpers to generate RESTful links?
I'm trying to use Html.ActionLink to generate a link with in this form:
/Action/Model/Id/Parameter1/Parameter2
I've used:
<%= Html.ActionLink("Link Text", "Action", "Model", new { id = var, parament1=var1 }, null) %>
but it always ends up looking like /Action/Model/Id?parameter1=variable
I've seen similar questions on Stackoverflow and elsewhere, but I can't find a solution that works/makes sense. Any help would be appreciated.
@John: I have the following route registered: routes.MapRoute("Alternate","{controller}/{action}/{id}/{Heading}", new { controller = "Designation", action = "Detai开发者_C百科ls", id = "", Heading = "" }
I then have the following code in my view: <%= Html.ActionLink("Link Text", "Action", "Model", new { Id = model.Id, Heading = model.Heading }, null) %>
I get /Model/Action/Id?Heading=var1 I want it as /Model/Action/Id/var1
ANSWER: I added the following route to my global.asax.cs file and the links generated correctly. routes.MapRoute("Something", "MyModel/MyAction/{Id}/{Heading}", new { controller = "MyModel", action = "MyAction", id = "", heading = "" }, new { controller = @"[^.]*" });
精彩评论