Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Check Querystring

Reply
Thread Tools

Check Querystring

 
 
Deepster
Guest
Posts: n/a
 
      01-27-2005
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

 
Reply With Quote
 
 
 
 
Phill. W
Guest
Posts: n/a
 
      01-28-2005
"Deepster" <> wrote in message
news: oups.com...
> 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.


 
Reply With Quote
 
 
 
 
teknohippy
Guest
Posts: n/a
 
      01-28-2005
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
 
Reply With Quote
 
Deepster
Guest
Posts: n/a
 
      01-28-2005
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

 
Reply With Quote
 
Adrienne
Guest
Posts: n/a
 
      02-02-2005
Gazing into my crystal ball I observed "Deepster" <>
writing in news: ups.com:

> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get value of QueryString inside QueryString Mehdi ASP .Net 6 04-06-2006 03:41 PM
Passing QueryString URL as a paremeter in QueryString Adeel Ahmad ASP General 1 03-07-2006 02:05 PM
Check existance of a querystring variable Imran Aziz ASP .Net 2 08-09-2005 10:51 AM
Check Existence of QueryString Keith ASP General 5 02-05-2005 08:38 PM
Querystring Check Deepiceman ASP General 1 08-21-2003 07:54 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57