Welcome to Mediachase Community Sign in | Join | Help    
in Search   

SiteMapProvider - FindSiteMapNode bug

Last post Mon, Jul 27 2009, 12:55 AM by ga. 3 replies.
Sort Posts: Previous Next
  •  Wed, Feb 06 2008, 10:28 AM 7669

    SiteMapProvider - FindSiteMapNode bug

    The method FindSiteMapNode of SiteMapProvider is not working correctly when the StartingNodeUrl is specified by a SiteMapDatasource.

    In order to correct this bug we altered the code as shown bellow.

    This issue needs to be resolved though in a future release. Don' t you think so?

    public override SiteMapNode FindSiteMapNode(string rawUrl)
            {
                // If url is rewritten, that means that virtual page is used and when page node is not null
                if (ClientContext.Context.IsUrlReWritten && HttpContext.Current.Items["PageNode"] != null)
                {
                    SiteNode node = (SiteNode)HttpContext.Current.Items["PageNode"]; // GetNode("p_" + CommonHelper.GetRelativeUrl(rawUrl));
                    //if (node.Ancestors != null && node.Ancestors.Length > 0)
                      //  return CreateSiteMapNode(node.Ancestors[0]);
                    //else
                    if (node == null)
                        return null;
    
                    return CreateSiteMapNode(node);
                }
                else
                {
                    //object cidObject = HttpContext.Current.Request.QueryString["cid"];
                    //object idObject = HttpContext.Current.Request.QueryString["id"];
    
                    //Nortech 
                    object cidObject = null;
                    object idObject = null;
    
                    if (rawUrl.Contains("StartingNodeUrl_"))
                    {
                        string []str;
                        str = rawUrl.Split(',','.');
    
                        if (str!=null)
                            cidObject = str[1];    
                    }
                    else
                    {
                        cidObject = HttpContext.Current.Request.QueryString["cid"];
                        idObject = HttpContext.Current.Request.QueryString["id"];
                    }
    
                    
                    
                    if (cidObject != null)
                    {
                        return CreateSiteMapNode(GetNode("c_" + cidObject.ToString()));
                    }
                    else if (idObject != null)
                    {
                        return CreateSiteMapNode(GetNodeFromProduct(idObject.ToString()));
                    }
    
    
    

    . . .


    Nortech
  •  Fri, Feb 29 2008, 9:52 AM 7851 in reply to 7669

    Re: SiteMapProvider - FindSiteMapNode bug

    Thank you very much for posting this fix to the forums.  We will review it and consider it for a future maintenance release.

    Mediachase Software

  •  Fri, Jul 17 2009, 12:03 PM 11076 in reply to 7851

    Re: SiteMapProvider - FindSiteMapNode bug

    This still hasn't been fixed!!!
    The newest code is:
            public override SiteMapNode FindSiteMapNode(string rawUrl)
            {
                // If url is rewritten, that means that virtual page is used and when page node is not null
                if (ClientContext.Context.IsUrlReWritten && HttpContext.Current.Items["PageNode"] != null)
                {
                    SiteNode node = (SiteNode)HttpContext.Current.Items["PageNode"]; // GetNode("p_" + CommonHelper.GetRelativeUrl(rawUrl));
                    //if (node.Ancestors != null && node.Ancestors.Length > 0)
                      //  return CreateSiteMapNode(node.Ancestors[0]);
                    //else
                    if (node == null)
                        return null;

                    return CreateSiteMapNode(node);
                }
                else
                {
                    object cidObject = HttpContext.Current.Request.QueryString["cid"];
                    object idObject = HttpContext.Current.Request.QueryString["id"];
                    if (cidObject != null)
                    {
                        return CreateSiteMapNode(GetNode("c_" + cidObject.ToString()));
                    }
                    else if (idObject != null)
                    {
                        return CreateSiteMapNode(GetNodeFromProduct(idObject.ToString()));
                    }

                    int index = rawUrl.IndexOf("?");
                    if (index > 0)
                    {
                        string queryString = rawUrl.Substring(index + 1);
                        string[] queryStringArray = queryString.Split(new char[] { '=' });
                        bool found = false;
                        string cid = String.Empty;
                        foreach (string item in queryStringArray)
                        {
                            if (found)
                            {
                                cid = item;
                                break;
                            }

                            if (item.CompareTo("cid") == 0)
                            {
                                found = true;
                            }

                        }

                        //System.Web.HttpContext.Current.Response.Write(cid);
                        if (cid != String.Empty)
                        {
                            return CreateSiteMapNode(GetNode("c_" + cid));
                        }
                    }

                    return RootNode;
                }

            }
    When the SiteMapDataSource is set to StartingNodeUrl="~/catalog/Products,230.aspx" to show cid=230 the node returned is RootNode because in the code,
                    object cidObject = HttpContext.Current.Request.QueryString["cid"];
                    object idObject = HttpContext.Current.Request.QueryString["id"];
                    if (cidObject != null)
    cidObject is never null so it gets the node c_0.

    rawUrl is "/PublicStore/catalog/Products,230.aspx" when StartingNodeUrl="~/catalog/Products,230.aspx" in the SiteMapDataSource.

    Can someone take a quick look at how to make this work properly?


  •  Mon, Jul 27 2009, 12:55 AM 11087 in reply to 11076

    Re: SiteMapProvider - FindSiteMapNode bug

    Hi,
    when you specify "StartingNodeUrl" in SiteMapDataSource this url in not passes through url rewriting module which is used for all requests. That is why you StartingNodeUrl is not processed correctly. If you want to use that url format (/Product,###.aspx) you can parse the url as it is offered earlier in this post.

    Otherwise you can specify StartingNodeUrl in other format "~/catalog/productinfo.aspx?id=###&cid=###". Please see section <urlrewritingnet> in web.config file of PublicStore project. In this format "id" is Product id, and "cid" is CategoryId.

    Hope this helps.

View as RSS news feed in XML
Site Terms | Privacy Policy | About Us | Contact Us
Running on Mediachase eCommerce Framework 4.0.
  Copyright © Mediachase, LTD. 1997-2006. All Rights Reserved

E-commerce, HelpDesk, Service Desk & Project Management Software, alternatives to Microsoft Project Server & Sharepoint Collaboration Server
project management software | microsoft project server | sharepoint collaboration server | issues management, helpdesk & service desk
Powered by Community Server, by Telligent Systems