配置 ASP.NET 站点地图 URL 域

发布于 2024-09-04 04:02:10 字数 1945 浏览 2 评论 0原文

我有一个这样配置的站点地图:

<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>" & "&nbsp;&gt;&nbsp;" & path
        Loop While currentNode IsNot SiteMap.Providers(type).RootNode

        SitePath = path
        Exit Function
    End If
    SitePath = ""
End Function

由于某种原因,即使在站点地图中,网址也定义为“www.website.com/index.aspx”或“home.aspx”。 aspx”,currentNode.URL 总是将域附加到 URL,创建错误的 url,如“www.domain.com/www.website.com/index.aspx”

我试图找出 www.domain.com 在哪里来自我的项目和 web.config 文件中的搜索,但我似乎找不到它。

有什么想法或建议吗?

I have a site map configured as such:

<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"/>

I have a custom breadcrumb function that looks like this:

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

For some reason, even though in the sitemap, the url is defined as "www.website.com/index.aspx" or "home.aspx", the currentNode.URL always has the domain attached to the URL, creating bad urls like "www.domain.com/www.website.com/index.aspx"

I've tried to figure out where www.domain.com was coming from by search my project and inside of my web.config file, but I can't seem to find it.

Any ideas or suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你在我安 2024-09-11 04:02:10

我找到了原因。

该域是在 web.config 文件内的

    <appSettings>
    <add key="domain" value="www.domain.com" />
    </appSettings>

子目录下配置的,因为应用程序托管在虚拟目录内。两者的结合就是 sitenode 创建 url 的方式。

I found the reason why.

The domain was configured inside of the web.config file, under

    <appSettings>
    <add key="domain" value="www.domain.com" />
    </appSettings>

The subdirectory was due to the fact that the application was hosted inside of a virtual directory. The combination of the two is how the sitenode created the urls.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文