A user found an interesting issue in the SiteMapProvider code.  It seems that if you have a node that has a url such as: "~/home.aspx?p=some text"  (notice the space in the query string) and you are actually navigated to that url, SiteMap.CurrentNode doesn't actually return the correct node.  The reason for this is that the url actually comes in as:  "/home.aspx?p=some%20text". 

Now, firstly, this is a bug, and it's been filed to be addressed in the future but what (if any) is the workaround?  This one is tricky because the issue is pretty deep.  You need a custom provider and the appropriate method overridden.  When the user raised the issue, I thought about it and decided I could come up with the solution in 5 minutes or let him struggle with it for an hour.  What do you think I did?

Here's the custom provider:

Public Class testProvider : Inherits XmlSiteMapProvider

    
Public Overrides Function FindSiteMapNode(ByVal context As System.Web.HttpContext) As System.Web.SiteMapNode
        
Dim node As SiteMapNode = MyBase.FindSiteMapNode(context)

        
If node Is Nothing Then
            If context Is Nothing Then
                Return Nothing
            End If

            Dim queryString As String = CType(context.CurrentHandler, Page).ClientQueryString

            
Dim pageUrl As String = HttpUtility.UrlDecode(context.Request.Path & "?" & queryString)
            node =
MyBase.FindSiteMapNode(pageUrl)
        
End If

        Return node
    
End Function

End
Class