0

動的サイトマップを作成する独自のstaticsitemapproviderを作成しました。私が抱えている問題は、ページのクエリ文字列に無視する必要のある追加のパラメータが含まれる場合があることです。

    Public Overrides Function FindSiteMapNode(ByVal rawUrl As String) As SiteMapNode

    Dim startpos As Integer = 0
    Dim endpos As Integer = 0

    If rawUrl.Contains("pagetype=") Then
        startpos = rawUrl.IndexOf("pagetype=")
        endpos = rawUrl.IndexOf("&", startpos) + 1
        If endpos >= startpos Then
            'not the last param
            rawUrl = rawUrl.Remove(startpos, endpos - startpos)
        Else
            'must be the last param
            rawUrl = rawUrl.Remove(startpos)
        End If
    End If

    Return MyBase.FindSiteMapNode(rawUrl)

End Function

また、HttpContectオブジェクトを取り込むFindSiteMapNode関数をオーバーライドしました。これを使用して、そのリクエストのURLを簡単に見つけて、上記と同じ関数で実行します。

ただし、これを使用すると、(サイトマップにバインドされている)私のサイトマップパスはすべてのページで何も返しません。

4

1 に答える 1

0

結局、これは非常に簡単な修正であることが判明しました。私がする必要があるのは、パラメータがURLの最初であるかどうかを確認することだけでした。そうでない場合は、アンパサンドを削除する必要もありました。startpos - 1

乾杯

于 2010-11-15T13:31:25.343 に答える