Write URL to custom route in Razor
asp.net-mvc, html.actionlink, parameters, razor, url
Solution
<a href="@Url.RouteUrl("Profile", new { aScreenName = "yourScreenName" })">click here</a>
or
@Html.ActionLink("click here", "Index", "Profile", new { aScreenName = "yourScreenName" })
Problem
I have declared custom routes similar to this: ASP.MVC routes without Details action Here is my route: ``` routes.MapRoute( name: "Profile", url: "Profile/{aScreenName}", defaults: new { controller = "Profile", action = "Index", aScreenName = UrlParameter.Optional } ); ``` I thought this looked neater, but now I am struggling to find a way to create a hyperlink to these routes in Razor. The problem is everything I try wants an object and automatically tries to treat it as a full query string. I can't find the right helper to do this. I have tried `@html`, `@url`, and `@href`. Does anybody know the best way to do this?