Pass queryString with the Sitemap Node

Last post 07-05-2009 12:53 AM by Bobby-Z. 6 replies.

Sort Posts:

  • Pass queryString with the Sitemap Node

    07-03-2009, 7:03 AM

    Dear Friends. 
    I have an application and I want to pass a QueryString inside the sitemap URL... How can I do that.??
    <?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="" >
            <siteMapNode url="Browse.aspx" title="Browse"  description="" />
          <siteMapNode url="ShoppingCart.aspx" title="Shopping Cart"  description="" />
          <siteMapNode url="MyAccount.aspx?userID=UserID" title="My Account"  description="" />  (here it does not work !)
          <siteMapNode url="OrderTracking.aspx" title="Order Tracking"  description="" />
          <siteMapNode url="AboutUs.aspx" title="About Us"  description="" />
          <siteMapNode url="ContactUs.aspx" title="Contact Us"  description="" />
        </siteMapNode>
    </siteMap>

    Dear Friends. 


    I have an application and I want to pass a QueryString inside the sitemap URL... How can I do that.??



    <?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="" >

            <siteMapNode url="Browse.aspx" title="Browse"  description="" />

          <siteMapNode url="ShoppingCart.aspx" title="Shopping Cart"  description="" />

          <siteMapNode url="MyAccount.aspx?userID=UserID" title="My Account"  description="" />  (here it does not work !)

          <siteMapNode url="OrderTracking.aspx" title="Order Tracking"  description="" />

          <siteMapNode url="AboutUs.aspx" title="About Us"  description="" />

          <siteMapNode url="ContactUs.aspx" title="Contact Us"  description="" />

        </siteMapNode>

    </siteMap>



    Please advice,


    regds

    Avantha Siriwardana 

    Avantha Siriwardana
    Beware of bugs in the above code; I have only proved it correct, not tried it.
    (Donald Knuth)
    http://www.linkedin.com/in/avanthasiriwardana
  • Re: Pass queryString with the Sitemap Node

    07-03-2009, 10:34 AM
    • Contributor
      5,600 point Contributor
    • integrasol
    • Member since 06-05-2009, 3:18 PM
    • Posts 1,041

    It works fine here, but where does it go wrong at your end? Does the query string not get passed on, or is it on the destination page you have problems?

    Thanks and HTH

    Carsten

    Please mark this post as Answer if it is of help to you. :-)
  • Re: Pass queryString with the Sitemap Node

    07-03-2009, 12:28 PM
    • All-Star
      16,570 point All-Star
    • Dave Sussman
    • Member since 06-17-2002, 11:53 AM
    • UK
    • Posts 2,299
    • ASPInsiders
      TrustedFriends-MVPs

    The query string that gets passed is exactly what you type, so your query string contains UserID=UserID, which I assume isn't what you want; I guess you want the value of some UserID variable passed in there. So, the question is, where does that UserID come from? Is it just the ID of the currently logged in user? If so you don't need to pass it in because it's available from the membership system. Or is it coming from wsomewhere else?

  • Re: Pass queryString with the Sitemap Node

    07-04-2009, 1:43 AM

    Hi Dave Sussman

    I'm pretty much happy cause you have reached to the point I want. I have a loggin control in my homepage and once the user logs in it should pass to the other pages Via the sitemap as well. But the thing is I don’t use that in built membership and user controls since I have my own created database for handling user details. When user clicks on the site map, userID should go into the next page and the output should look like this. http://localhost:1442/Web/MyAccount.aspx?userID=2

    Avantha Siriwardana
    Beware of bugs in the above code; I have only proved it correct, not tried it.
    (Donald Knuth)
    http://www.linkedin.com/in/avanthasiriwardana
  • Re: Pass queryString with the Sitemap Node

    07-04-2009, 4:42 AM
    Answer
    • All-Star
      16,570 point All-Star
    • Dave Sussman
    • Member since 06-17-2002, 11:53 AM
    • UK
    • Posts 2,299
    • ASPInsiders
      TrustedFriends-MVPs

    The first thing you should do is NOT pass the user id int he query string, because it's visible to users. That means they could just alter the query string value in the browser address bar and pretend they were another user. The simplest solution is to store it in the session. So when the user logs in just do:

    Session("UserID") = 1

    Then in your other pages you can just have:

    Dim UserID as Integer = Integer.Parse(Session("UserID"))

    In fact, if you need to protect pages so that users have to be logged in, do:

    Dim UserID As Integer
    If String.IsNullOrEmpty(Session("UserID") Then
      Response.Redirect("Login.aspx")
    Else
      UserID = Integer.Parse(Session("UserID"))
    End If

     

  • Re: Pass queryString with the Sitemap Node

    07-05-2009, 12:50 AM
    Answer
    • Member
      640 point Member
    • Bobby-Z
    • Member since 10-04-2008, 1:53 AM
    • Orange County, CA
    • Posts 271

     It looks fine, but are you receiving it on the other page. ie Have your programmed it to receive the query (Visual Basic)

    request.querystring("UserID").ToString

    so lets say you are using it to display a xslt transfom fro an xml datasource

    XmlDataSource1.TransformSource = "../file_" + request.querystring("ID") = ".xsl"

    What you have will work but it is like having a QB without a receiver on the second page.

    I don't know if this was your problem, but I hope it helped you to check through your problem step by step

    "Success is the Sum of Small Efforts, Repeated Day in and Day Out - Without Ceasing!"

    Robert Hall
    CEO and Founder
    My Service Solutions, Inc.
  • Re: Pass queryString with the Sitemap Node

    07-05-2009, 12:53 AM
    • Member
      640 point Member
    • Bobby-Z
    • Member since 10-04-2008, 1:53 AM
    • Orange County, CA
    • Posts 271

     It looks fine, but are you receiving it on the other page. ie Have your programmed it to receive the query (Visual Basic)

    request.querystring("UserID").ToString

    so lets say you are using it to display a xslt transfom fro an xml datasource

    XmlDataSource1.TransformSource = "../file_" + request.querystring("ID") = ".xsl"

    What you have will work but it is like having a QB without a receiver on the second page.

    I don't know if this was your problem, but I hope it helped you to check through your problem step by step

    but yes he is right you do NOT want to pass a user id through a querystring since it is readable.

    The better thing to do is pass your values to the next page, then get the userID.

    "Success is the Sum of Small Efforts, Repeated Day in and Day Out - Without Ceasing!"

    Robert Hall
    CEO and Founder
    My Service Solutions, Inc.
Page 1 of 1 (7 items)