asp.net mvc - HtmlHelper.GenerateRouteLink doesn't give expected result -
I (strictly) trying to create a link from one of my controllers
It should look like this:
Relevant (though probably incorrect) route:
routes. MapRoute ("UsersRoute", // root name "{controller} / {action} / {userId} / {key}", new {controller = "user", action = "profile", userId = UrlParameter.Optional, key = UrlParameter.Optional}); and link code:
HtmlHelper.GenerateRouteLink (requestContext, RouteTable.Routes, "MyLinkText", "UsersRoute", New RouteValueDictionary (New {userId} = UserId, key = hash password (password)}, tap; (Where I send the request reference: HttpContext.Request.RequestContext . It currently gives me:
& lt; a href = "http: // account / registration / 29 / e96303852080b94cc 230611a3f 4806" target = "_ Blank"> MyLinkText
Any help would be greatly appreciated.
Your route definition URL will be of the form:
{p>
{controller} / {action} ) I can not see that you have a URL of the form ( {code> userid < / Code> and key token: / user / profile Why do not you just leave the default URL definition?
routes.Ma PRoute ("default", "{controller} / {action} / {id}", new {controller = "home", action = "index", id = UrlParameter .Optional}); You can only get the URL of the desired form:
@ html.ActionLink ("MyLinkText", "Profile", "Users", New {userId = userId, key = hash password (password)}, empty)
Comments
Post a Comment