【问题标题】:Appending Url Fragments to MVC Routes?将 URL 片段附加到 MVC 路由?
【发布时间】:2011-11-06 16:04:42
【问题描述】:

我想在我的 ASP.NET MVC 3 Web 应用程序中设置一个路由,该路由附加一个 url 片段,与 StackOverflow 上的某些 url 相同,例如:

http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732382#1732382

但是,我目前看不到任何(干净的)方法来实现这一点。

是否有“开箱即用”的解决方案,或者我是否需要构建一些描述的助手以将 url 片段附加到正常路由的末尾?

【问题讨论】:

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


    【解决方案1】:

    你可以使用助手。例如:

    @Html.ActionLink(
        "linkText", 
        "action", 
        "controller", 
        null, 
        null, 
        "fragment", 
        new { id = "123" }, 
        new { @class = "test" }
    )
    

    或者如果你只想要一个 url,你可以使用 GenerateUrl 方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-16
      • 2017-02-07
      • 1970-01-01
      相关资源
      最近更新 更多