c# - how do I add a url parameter to a routelink in asp.net mvc? -


Everything else, my position is that I have a basic route, as well as a few other simple routes:

  routes.MapRoute ("default", "{controller} / {action} / {id}", new {controller = "home", action = "index", id = 1});  

The following URL works:

However, some of my index pages take the URL parameters in the following frame:

How do I use HTML? Rutelink to link to this?

You can not do add? ' In this way, for routes in the global ASX file:

  routes. MapRoute ("tags", "tag / index / {id}? When = {when}", new {controller = "tag", action = "index", id = "", when = ""}};  

If this route works, then I can link it using:

  html.routeLink (string.format ("{0} ", Link.Rating)," link ", new {id = link.ReferenceId, when = model. When}}  

but it's not! So I'm not sure how I will use HTML.

to generate a rootlink. You do not map the regular Html.RouteLink and any object properties to the URL in your global URL, this adds to the URL parameter.

By using this route:

routes. Map route ("link", "link / description / {id}", new {admin = "link", action = "description", id = ""} defaults);

and this rarulink:

  html Root Link ("link text", "link", new {id = link. Reference id, when = model. When})  

generates correct url:


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -