c# - MVC RouteLink URL format -


i have following routelink:

@html.routelink("accept offer", new { controller = "case", action = "accept", id = item.caseid, offerid = item.pxofferid }, new { @class = "btn btn-success" }) 

which formats url as:

http://localhost:54644/clients/case/accept/15847?offerid=3103 

how format url be:

http://localhost:54644/clients/case/accept/15847/3103 

thanks.

default route:

    context.maproute(         "clients_default",         "clients/{controller}/{action}/{id}",         new { controller = "login", action = "index", id = urlparameter.optional }     ); 

route works if put first in defined routes:

    context.maproute(         name: "accept offer",         url: "clients/{controller}/{action}/{id}/{offerid}",         defaults: new { controller = "case", action = "accept", id = 0, offerid = urlparameter.optional }     ); 

but causes errors on other pages.

you nee route in routeconfig file in app_start (if using mvc3/4 routes might configured in global.asax file instead):

routes.maproute(     name: "mycaseroute",     url: "/clients/{controller}/{action}/{id}/{offerid}",     defaults: new { controller = "case", action = "accept", id = urlparameter.optional, offerid = urlparameter.optional } ); 

usage:

@html.routelink("my link text", routename: "mycaseroute", routevalues: new { controller = "case", action = "accept", id = 1, offerid = 2 }) 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -