[Sitemap] Same url, different path (query parameters)

Last post 09-07-2009 5:49 AM by blanciq. 8 replies.

Sort Posts:

  • [Sitemap] Same url, different path (query parameters)

    09-03-2009, 7:12 AM
    • Member
      point Member
    • blanciq
    • Member since 09-03-2009, 6:56 AM
    • Posts 5

    Hi,

    I've gotta huge problem with sitemap. I'm writting asp application to help administrate a systems, which is installed on two machines(test and prod enviroment). My web application need to provide users to choose which enviroment they want to administrate. So i created sitemap and path like: home->prod->do_sth, and home->prod->do_sth, but the issue is that the "do_sth" is the same for the prod and test enviroment and this is the same web page (the same url) but different param im querystring. Until the url is the same for both sides, i cannot put it into web.sitemap like this:

    <?xml version="1.0" encoding="utf-8" ?>
    <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
        <siteMapNode url="~/Default.aspx" title="Home page"  description="Home Page">
            <siteMapNode url="~/Test.aspx" title="Test" >
              <siteMapNode url="~/Page.aspx" title="Do_sth" />
            </siteMapNode>
            <siteMapNode url="~/Prod.aspx" title="Prod" >
              <siteMapNode url="~/Page.aspx" title="Do_sth" />
            </siteMapNode>
            <siteMapNode url="" title="raports"  description="Generate Raports" />
        </siteMapNode>
    </siteMap>
    


    Also i've tried to use urls like "~/Page.aspx?env=prod" and "~/Page.aspx?env=test" but it's still not working.

    I have to add that i'm using TreeView for navigate and SiteMapPath as a eyebrow as well.

    The same issue i've got with the same operations (pages) for multiple systems(different databeses with the same structure), so i wanted to do parametrized pages with data bases' name in querystring. But page url are the same for all systems.

    How can i resolve my problem using ASP.NET Sitemap ?

  • Re: [Sitemap] Same url, different path (query parameters)

    09-03-2009, 7:45 AM
    • All-Star
      36,106 point All-Star
    • rtpHarry
    • Member since 10-01-2006, 8:51 AM
    • Lincoln, England
    • Posts 5,817

    Hi,

    The sitemap only supports listing urls once per sitemap. I think it lets you put them in but then just matches the first one it finds at runtime.

    You can edit the sitemap in memory like this forums example for a dynamic breadcrumb:


    Perhaps the best idea would be to put the code from Page.aspx in a usercontrol and then split page.aspx into two pages that both contain the same usercontrol.

  • Re: [Sitemap] Same url, different path (query parameters)

    09-03-2009, 8:04 AM
    • Member
      point Member
    • blanciq
    • Member since 09-03-2009, 6:56 AM
    • Posts 5

    I know that sitemap supports only unique urls, so this couse my problem. (i cant even put double url into web.sitemap - runtime error)

    Editing sitemap in memory can't help me, because i can edit title or even url for breadcrumb purpose but not for my TreeView menu. I've dept into this subject, but it's not solution for my problem, because i need two (or more) brunches with the same page(different querystring params).

    I've considered idea with usercontrol, it seems to be pretty good solution but it's not the best one for sure. Still it obligate me to create multiple files (a set per system) and create parametrized usercontrol and on each page use this control. It's better than nothing but i'm looking for better solution...

    Anyone ?

  • Re: [Sitemap] Same url, different path (query parameters)

    09-03-2009, 9:36 AM
    • All-Star
      16,931 point All-Star
    • Dave Sussman
    • Member since 06-17-2002, 11:53 AM
    • UK
    • Posts 2,344
    • TrustedFriends-MVPs

    Can you explain a bit more about why the query strings don't work for you? It's a technique I've used in the past.

  • Re: [Sitemap] Same url, different path (query parameters)

    09-03-2009, 9:45 AM
    • Member
      point Member
    • blanciq
    • Member since 09-03-2009, 6:56 AM
    • Posts 5

    <?xml version="1.0" encoding="utf-8" ?>
    <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
        <siteMapNode url="~/Default.aspx" title="Home page"  description="Home Page">
            <siteMapNode url="~/Test.aspx" title="Test" >
              <siteMapNode url="~/Page.aspx" title="Do_sth" />
            </siteMapNode>
            <siteMapNode url="~/Prod.aspx" title="Prod" >
              <siteMapNode url="~/Page.aspx" title="Do_sth" />
            </siteMapNode>
            <siteMapNode url="" title="raports"  description="Generate Raports" />
        </siteMapNode>
    </siteMap>
    


    When i've wrote such sitemap and run page "~/Page.aspx?env=prod" there is no match in sitemap (breadcrumb was empty)

  • Re: [Sitemap] Same url, different path (query parameters)

    09-03-2009, 10:45 AM
    Answer
    • All-Star
      16,931 point All-Star
    • Dave Sussman
    • Member since 06-17-2002, 11:53 AM
    • UK
    • Posts 2,344
    • TrustedFriends-MVPs

    If you have the following in your sitemap:

    <?xml version="1.0" encoding="utf-8" ?>  
    <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >  
        <siteMapNode url="~/Default.aspx" title="Home page"  description="Home Page">  
            <siteMapNode url="~/Test.aspx" title="Test" >  
              <siteMapNode url="~/Page.aspx?env=Test" title="Do_sth" />  
            </siteMapNode>  
            <siteMapNode url="~/Prod.aspx" title="Prod" >  
              <siteMapNode url="~/Page.aspx?env=Prod" title="Do_sth" />  
            </siteMapNode>  
            <siteMapNode url="" title="raports"  description="Generate Raports" />  
        </siteMapNode>  
    </siteMap> 

    Then the path should match when you navigate to it. If you include a query string in the site map node itself, then you must include that query string in any navigation elements. This isn't a problem if you build your navigation from the sitemap, but can be an issue if you manually have links on the page.

  • Re: [Sitemap] Same url, different path (query parameters)

    09-07-2009, 3:42 AM
    • Member
      point Member
    • blanciq
    • Member since 09-03-2009, 6:56 AM
    • Posts 5

    I forgot add query string in sitemap, but there should be "~/Page.aspx?env=Test" in web.sitemap. And yes, it works from TreeView, but i have to create links manually (and add more querystrings), so my finally link looks like "~/Page.aspx?env=Test&id=1234". So nobody has any idea for solving this issue ?

  • Re: [Sitemap] Same url, different path (query parameters)

    09-07-2009, 4:06 AM
    • All-Star
      16,931 point All-Star
    • Dave Sussman
    • Member since 06-17-2002, 11:53 AM
    • UK
    • Posts 2,344
    • TrustedFriends-MVPs

    That's just the way sitemaps work I'm afraid, you have to have the query string in the URL if it's to match.

    You could consider another approach. Instead of having two sets of menus, perhaps have another form of selection - maybe radio buttons or a drop down list - on the master page that allows the user to select which system they want to admin. Then the admin pages just read this value from the master page, instead of reading it from the query string.

  • Re: [Sitemap] Same url, different path (query parameters)

    09-07-2009, 5:49 AM
    • Member
      point Member
    • blanciq
    • Member since 09-03-2009, 6:56 AM
    • Posts 5

    It is pretty good solution, but my supervisor told me to do this with TreeView, but maybe i could persuade him to this approach.


    Thanks everyone for help.

Page 1 of 1 (9 items)