Check Querystring

Discussion in 'ASP General' started by Deepster, Jan 27, 2005.

  1. Deepster

    Deepster Guest

    Hi Guys
    Here is what I am doing ... Have a page default.asp which looks at the
    url and checks for querystring's. if there are none passed goes to a
    function. if there are particular querystrings passed goes to the
    respective function.
    Now there can be only 2 valid querystrings that can be passed and only
    one at a time. How to do i check for querystrings that dont exist and
    send them to error page?

    for example I have QS(querystring) ID and State. only one can exist at
    a time or none. if I pass QS country along with one of those two, it
    still goes to that function. Can I look for querystring that shouldnt
    be valid in my case and redirect them to error page?

    Here is my code! thanks

    ***********************

    If (Request.QueryString("ID") <> "") Then
    If (Request.QueryString("State") <> "") Then
    Response.Redirect("error.asp")
    Else
    rs__MMColParam = Request.QueryString("ID")
    display()
    End if
    Else if (Request.QueryString("State") <> "") Then
    statereq = Request.QueryString("State") 'statereq --- State requested
    select case statereq
    case "AL"
    alreq()
    case "AZ"
    azreq()
    case "CO"
    coreq()
    case "FL"
    flreq()
    case "IN"
    inreq()
    case "MI"
    mireq()
    case "OH"
    ohreq()
    case "OR"
    orreq()
    case "VA"
    vareq()
    case "WA"
    wareq()
    case "APTS"
    aptsreq()
    case else
    Response.Redirect "error.asp"
    end select
    Else
    normal()
    End If
    End If
     
    Deepster, Jan 27, 2005
    #1
    1. Advertising

  2. Deepster

    Phill. W Guest

    "Deepster" <> wrote in message
    news:...
    > Now there can be only 2 valid querystrings that can be passed and only
    > one at a time. How to do i check for querystrings that dont exist and
    > send them to error page?


    For Each eArg in Request.QueryString
    Select Case eArg
    Case "ID"
    ' We were given an ID - deal with it
    ' Check for QS( "State" ) as well, or simply give ID priority

    Case "State"
    ' We were given a State - deal with that

    Case Else
    ' Don't know /what/ this is ...
    ' Off the error page we go ...

    End Select
    Next

    HTH,
    Phill W.
     
    Phill. W, Jan 28, 2005
    #2
    1. Advertising

  3. Deepster

    teknohippy Guest

    On 27 Jan 2005 14:26:06 -0800, "Deepster" <>
    wrote:

    >Here is my code! thanks
    >
    >***********************
    >
    >If (Request.QueryString("ID") <> "") Then
    >If (Request.QueryString("State") <> "") Then
    >Response.Redirect("error.asp")
    >Else
    >rs__MMColParam = Request.QueryString("ID")
    >display()
    >End if
    >Else if (Request.QueryString("State") <> "") Then
    >statereq = Request.QueryString("State") 'statereq --- State requested
    >select case statereq
    >case "AL"
    >alreq()
    >case "AZ"
    >azreq()
    >case "CO"
    >coreq()
    >case "FL"
    >flreq()
    >case "IN"
    >inreq()
    >case "MI"
    >mireq()
    >case "OH"
    >ohreq()
    >case "OR"
    >orreq()
    >case "VA"
    >vareq()
    >case "WA"
    >wareq()
    >case "APTS"
    >aptsreq()
    >case else
    >Response.Redirect "error.asp"
    >end select
    >Else
    > normal()
    >End If
    >End If



    What do the XXreq() functions do? Smells like there's lots of code
    replicated in them and you'd be better of with a single function and
    an argument?



    --
    Iain Norman | http://www.eliteforum.org
     
    teknohippy, Jan 28, 2005
    #3
  4. Deepster

    Deepster Guest

    Thanks for your help guys!

    As for describing how the site works, well user comes to my page gets
    the default page. If the user wants more information on state basis the
    default page loads with the querystring "State" and then I do select
    case to direct them to each functions. Once inside the state page they
    can click on individual results, this is where the querystring "id"
    comes into play and is passed on to the default page.
    Phil, I will try the code out and let you know how it goes.

    Thanks
     
    Deepster, Jan 28, 2005
    #4
  5. Deepster

    Adrienne Guest

    Gazing into my crystal ball I observed "Deepster" <>
    writing in news::

    > Thanks for your help guys!
    >
    > As for describing how the site works, well user comes to my page gets
    > the default page. If the user wants more information on state basis the
    > default page loads with the querystring "State" and then I do select
    > case to direct them to each functions. Once inside the state page they
    > can click on individual results, this is where the querystring "id"
    > comes into play and is passed on to the default page.
    > Phil, I will try the code out and let you know how it goes.
    >
    > Thanks
    >
    >


    Totally OT for this group, but if you can rename "id" to something else,
    you're not going to have problems with Google spidering it. Google won't
    spider URIs with "id" in the string.

    --
    Adrienne Boswell
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne, Feb 2, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Imran Aziz

    Check existance of a querystring variable

    Imran Aziz, Aug 9, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    30,567
    Imran Aziz
    Aug 9, 2005
  2. Mehdi
    Replies:
    6
    Views:
    36,135
    sloan
    Apr 6, 2006
  3. Deepiceman

    Querystring Check

    Deepiceman, Aug 21, 2003, in forum: ASP General
    Replies:
    1
    Views:
    84
  4. Keith

    Check Existence of QueryString

    Keith, Jan 31, 2005, in forum: ASP General
    Replies:
    5
    Views:
    285
    Dave Anderson
    Feb 5, 2005
  5. Adeel Ahmad
    Replies:
    1
    Views:
    532
    Anthony Jones
    Mar 7, 2006
Loading...

Share This Page