Request.querystring fun

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Javilen
    New Member
    • Sep 2007
    • 20

    Request.querystring fun

    Hello,

    I am developing a forums for asp.net, in doing this I am using code behind to do all validation on users and roles and then using embedded ASP to do the displaying for categories, sections and threads!

    The problem I am having is, when you first navigate to the site you pass the forum name in a querystring. So foe example: forumid=testfor um

    I do this because the site will host multiple forums and this will allow me to use one DB to host multiple forums.

    Anyway, it works fine the first time you visit the site but if you navigate away from the page, staying on the site, so you visit another page of the site, then come back to the page by clicking the link to the forums my page does not pick up the querystring.

    The url shows it being displayed but in the code, both behind and ASP side show that that

    Code:
    Dim forum_name as string = request.querystring(“ForumID”)
    This shows that the
    Code:
    request.querystring(“forumID”) = “”
    or to null.

    This also happens if I hit Refresh on the page.

    Please note that links are found in a master page(may be the problem)

    Anyone have any ideas please let me know.
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    moved to .NET forum. In dot net can you do something like this: [code=asp]for each x in request.queryst ring
    response.write x & ": " & request.queryst ring(x) & "<br>" & vbNewLine
    next[/code]? This is how I would address the problem in classic ASP. The reason is this will distinguish between not sending an argument and sending an empty querystring. If there is a querystring that is recognized as having no value, it should still be listed this way, but if a querystring is not recognized it shouldn't show up.

    Jared

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      I believe the keys are case sensitive?

      Comment

      • jhardman
        Recognized Expert Specialist
        • Jan 2007
        • 3405

        #4
        Originally posted by Plater
        I believe the keys are case sensitive?
        That might depend on what language is being used, classic ASP is case-insensitive,but it sure looks like he's using .NET. Anyway, I still think printing out all the data sent through the querystring is a good idea for troubleshooting purposes.

        Jared

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          True, but that won't show him the keys necessarily.


          To see all the a parameters (and their keys):
          Code:
          string n="";
          foreach (string key in Request.Params.AllKeys)
          {
             n += key + ": " + Request.Params[key] + "<br/>\r\n";
          }
          Response.WriteLine(n);
          For VB:
          [code=vbnet]
          Dim n As String = ""
          For Each key As String In Request.Params. AllKeys
          n += key + ": " + Request.Params( key) + "<br/>" & vbNewLine
          Next
          Response.WriteL ine(n)
          [/code]

          Comment

          Working...