我的Global.asax.vb页面中有一条这样的路线......
Shared Sub RegisterRoutes(ByVal routes As RouteCollection)
routes.IgnoreRoute("{resource}.axd/{*pathInfo}")
路线.MapRoute(_
“IdOnly”,_
“{ID}”, _
新的 {.controller = "Page", _
.action = "详细信息", _
.id = "7"} _
)
结束子
那id是我的主页。当有人导航到我的时显示:http://example.com/
但是,这也有效: http://example.com/7
我希望在我的网站上的任何地方都没有指向地址id为 7 的链接。但是,该Html.RouteLink()函数会生成这些链接。
对于作为主页子级的视图模型......
<%=Html.RouteLink(Model.Parent.Title, _
"IdOnly", _
New With {.id = Model.Parent.Id})%>
…生成以下锚标记:
<a href="/7">Home</a>
如何覆盖由我的主页函数href生成的?Html.RouteLink()