配置ASP.NET站点地图URL域
-
23-10-2019 - |
题
我有一个配置的站点地图:
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="www.website.com/index.aspx" title="Site Name" description="">
<siteMapNode url="home.aspx" title="My Home" description="My Home" Group="Active">
<siteMapNode url="Search.aspx" title="Search" description="Search For Roommate" Group="Active">
<siteMapNode url="SearchResults.aspx" title="Search Results" description="Roommate Search Results" Group="Active"/>
</siteMapNode>
<siteMapNode url="Extend.aspx" title="Extend Account" description="Extend Account" Group="Active"/>
<siteMapNode url="Hotlist.aspx" title="Hotlist" description="Hotlist" Group="Active"/>
我有一个自定义的面包屑功能,看起来像这样:
Public Shared Function SitePath(ByVal tr As String, Optional ByVal type As String = "REG") As String
If SiteMap.Providers(type).CurrentNode IsNot Nothing And SiteMap.Providers(type).CurrentNode IsNot SiteMap.Providers(type).RootNode Then
Dim currentNode As SiteMapNode
currentNode = SiteMap.Providers(type).CurrentNode
Dim path As String = currentNode.Title
Dim str As String = ""
Do
currentNode = currentNode.ParentNode
path = "<a href=""" & shsutils.generateURLSecure(currentNode.Url, tr & str) & """>" & currentNode.Title & "</a>" & " > " & path
Loop While currentNode IsNot SiteMap.Providers(type).RootNode
SitePath = path
Exit Function
End If
SitePath = ""
End Function
由于某种原因,即使在站点地图中,URL也被定义为“ www.website.com/index.aspx”或“ home.aspx”,currentnode.url始终在URL上附有域,创建不良URL,例如“ www.domain.com/www.website.com/index.aspx”
我试图找出www.domain.com从搜索项目和web.config文件内部来自何处,但我似乎找不到它。
有什么想法或建议吗?
解决方案
我找到了原因。
该域是在Web.config文件中配置的,
<appSettings>
<add key="domain" value="www.domain.com" />
</appSettings>
子目录是由于该应用程序是在虚拟目录内部托管的。两者的组合是SiteNode如何创建URL。
不隶属于 StackOverflow