2013-07-01 86 views
1

您好,我已宣布定制路由与此类似ASP.MVC routes without Details action写URL定制路线剃刀

这里是我的路线:

routes.MapRoute(
      name: "Profile", 
      url: "Profile/{aScreenName}", 
      defaults: new { controller = "Profile", action = "Index", aScreenName = UrlParameter.Optional } 
     ); 

我认为这看起来整洁,但现在我在努力寻找在剃刀上创建超链接到这些路线的方法。问题是我尝试的所有东西都需要一个对象,并自动尝试将其视为完整的查询字符串。我无法找到合适的帮手来做到这一点。我曾尝试@html @url @href。有没有人知道这样做的最佳方式?

感谢

保罗

回答

3
<a href="@Url.RouteUrl("Profile", new { aScreenName = "yourScreenName" })">click here</a> 

@Html.ActionLink("click here", "Index", "Profile", new { aScreenName = "yourScreenName" }) 
+0

感谢。我很亲密,我试过 Paul

+0

没问题保罗,很高兴你有工作:) –