0
votes

i am facing a big problem regarding persisting querystring attach with sitemap url

suppose i have three page

home > page1 > page2

i have one link which redirect me to page1 with query string like id=1

page1

i know how to attach query string with current site map link

i have another link in page1 for going to page2 like

page1

when i am in page2 and when i hover on the site map link for page2 then it is showing right url with query string but if i hover on the site map link for page1 then page1 link is not showing query string.

this is my problem. i am just not being able to persist the query string with site map link. only query string attach with current link.

so just tell me way out how to persist all the query string for different different site map link. if my question is not clear then please ask me.

i am looking for solution. thanks


EDITED Part

i have 3 aspx file one index.aspx,part1.aspx and part2.aspx. my sitemap control is there in a usercontrol and user control is added in all three aspx page.

so here is my sitemap file

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/default.aspx" title="Home"  description="The WebSite's Home Page"> </siteMapNode>
<siteMapNode url="~/part1.aspx" title="part1"  description="part1"></siteMapNode>
<siteMapNode url="~/part2.aspx" title="part2"  description="part2"></siteMapNode>

and the way i attach querystring with sitemap hyperlink using code like

SiteMapNode SmartSiteMapProvider_SiteMapResolve(object sender, SiteMapResolveEventArgs e)
    {
        string QryString = new Uri(HttpContext.Current.Request.Url.AbsoluteUri).Query;
        if ((SiteMap.CurrentNode == null)) return null;
        XmlSiteMapProvider @this = new XmlSiteMapProvider();
        SiteMapNode temp;
        temp = SiteMap.CurrentNode.Clone(true);
        //Uri u = new Uri(e.Context.Request.Url.ToString());
        SiteMapNode tempNode = temp;
        while (tempNode != null)
        {
            if (QryString!="")
            {
                if (tempNode != null)
                {
                    tempNode.Url += QryString;
                }
            }
            tempNode = tempNode.ParentNode;
        }
        return temp;
    }

actually i want questring should be persisten with sitemap link. suppose i am in index page and go to part1 page clicking on link from index page like part1/a>. the part1 sitemap link is showing query string. when i go to part2 page clicking on link from part1 page like part2/a>. then part2 page sitemap link is showing querystring but when i hover on the part1 sitemap link from part2 page then part1 link is not decorated with query string and this is my concern. when i attach query string with current link then why previous site map link is loosing query string...query string should be intact with all the sitemap link.

please help me. thanks

1

1 Answers

0
votes

this can be a bit tricky, especially if you are not using relative urls. I would suggest to always try using the "~" symbol. Also always resolve the urls by using this.ResolveUrl("~/page1.aspx"); If you post your SiteMap and some code, we would be able to help you more. Good luck!