0

我的 Global.asax 文件中有这段代码:

 Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs on application startup
        RegisterRoute(RouteTable.Routes)
    End Sub
    'about.aspx
    Sub RegisterRoute(ByVal _routes As RouteCollection)
        With _routes
            .MapPageRoute("homepage", "Home", "~/default.aspx")
            .MapPageRoute("aboutpage", "About", "~/about.aspx")
            .MapPageRoute("producs", "Products", "~/products/Default.aspx")
            .MapPageRoute("adFin", "Products/{name}", "~/products/Default.aspx")
            .MapPageRoute("news", "News", "~/news.aspx")
            .MapPageRoute("contact", "Contact", "~/contact.aspx")

        End With
    End Sub

每当我导航到 Product/Myproductname 时,它​​都可以正常工作,但是如果我导航回主页,则 url 仍然显示为 Product/Home 而不是 Home

4

1 回答 1

0

我的想法是您可能正在通过 ActionLink 方法生成链接——该方法使用当前控制器,即“产品”。您可能想在没有 HtmlHelper 的情况下手动创建链接 --- 只需链接到 Home

于 2012-07-17T14:40:49.817 回答