【问题标题】:Get URL address of Html.RouteLink result获取 Html.RouteLink 结果的 URL 地址
【发布时间】:2012-06-07 12:35:33
【问题描述】:

结果

@Html.RouteLink("link-name" , "route-name" , new 
{
  id = "8850" ,
  title = "sample-title" ,
  description = "sample-description"
}
)

<a href="/8850/sample-title/sample-description/">link-name</a>

有没有只提供href 地址的扩展方法?

【问题讨论】:

    标签: c# asp.net-mvc-3 url asp.net-mvc-routing


    【解决方案1】:

    您可以使用“Url.Action”

    UrlHelper 类:

    Action(string actionName, string controllerName, RouteValueDictionary routeValues);
    

    对于其他重载,请检查:

    UrlHelper.Action Method

    例如。

    <a href="@Url.Action(actionName, controllerName, routeValues)">link-name</a>
    

    【讨论】:

    • 如果路由已命名并具有预先确定的路由值,则另一种方法是使用 Url.RouteUrl。
    猜你喜欢
    • 2013-11-25
    • 1970-01-01
    • 1970-01-01
    • 2020-09-18
    • 2020-06-10
    • 2019-06-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多