troubleshooting Question

Detect if Querystring Key Exists

Avatar of jrram
jrramFlag for United States of America asked on
ASP
4 Comments1 Solution395 ViewsLast Modified:
I have a page where I am looking up recipes form a database.  Before executing my query, I'm trying to make sure the

== Method 1 ==

If Not IsNumeric(Request.Querystring("recipeID")) Then

     Response.Redirect("badURL.asp?y=badkeyvalue")

End If

This validation fails if the recipeID key is missing from the querystring.  It doesn't redirect to the badURL.asp page.  It continues on to my SQL cause it's expecting a value that isn't there.
Example: http://www.mysite.com/recipeLookup.asp?

== Method 2 ==

If Not (Request.Querystring("recipeID")) Then
     Response.Redirect("badURL.asp?y=keynoexist")
End If

I was hoping method 2 would make sure the key 'recipeID' was in the querystring, but it doesn't seem to be working.  It redirects either way regardless.

Any suggestions on how to make sure a key value exists?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros