2013-10-03 60 views
1

我有這個我global.asax如何使用的ASP.NET Web路由和網站地圖

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 

然後在我的母版,我有以下標記

<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工作正常,但如果我點擊在存檔鏈接沒有出現請幫助。

回答

0

您可以嘗試使用RouteValueDictionary在global.asax中爲參數「year」和「month」提供默認值。請檢查下面的文章瞭解詳情:

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