1

我有这个在我的global.asax

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)

    RegisterRoutes(RouteTable.Routes)

End Sub

Protected Shared Sub RegisterRoutes(ByVal routes As RouteCollection)

    ...        
    routes.MapPageRoute("aboutusRoute", "aboutus", "~/aboutus.aspx", True)
    routes.MapPageRoute("indexRoute", "index", "~/index.html", True)

    routes.MapPageRoute("archiveRoute", "archive/{year}/{month}","~/archive.aspx",True)
End Sub

然后在我的 Masterpage 我有以下标记

<asp:SiteMapPath ID="SiteMapPath1" runat="server" Style="margin-left: 5px" ParentLevelsDisplayed="2" SiteMapProvider="SiteMapLinks">
                                    <PathSeparatorTemplate>
                                        <asp:Image ID="Image2" runat="server" ImageUrl="/chuktex/Images/Seperator.png"  style="margin-right:5px"/></PathSeparatorTemplate>
                                </asp:SiteMapPath>
                                <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />

在我的web.sitemap我有以下

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >

    <siteMapNode url="~/home" title="Home"  description="Home">
      .
      .
      .
       <siteMapNode url="~/systemmaint/" title="System Maintainance"  description="System Maintainance" />
      <siteMapNode url="~/Login/" title="Login"  description="Login" />
      <siteMapNode url="~/Profile/" title="Profile"  description="Profile" />
      <siteMapNode url="~/archive/" title="Archive"  description="Archive" />
      .
      .
      .
    </siteMapNode>

</siteMap>

如果我单击指向 systemmaint 的链接,siteMapPath 工作正常,但如果我单击存档链接,则没有任何问题,请提供帮助。

4

1 回答 1

0

您可以尝试使用 RouteValueDictionary 为 global.asax 中的参数“年”和“月”提供默认值。请查看以下文章了解更多详情:

http://karmic-development.blogspot.in/2013/10/url-routing-in-aspnet-web-forms-part-2.html

此外,如果您在页面中包含了一些 javascript 文件,正常的 src 值可能不起作用。您需要将 javascript 文件的 src 提供为

src='<%= ResolveClientUrl("~/resource/lightbox_plus_min.js") %>'

谢谢和问候, Munjal

于 2013-10-07T13:26:01.717 回答