Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Is there a way to check for a specific variable in a query string?  (ASP.NET VB)

Posted on 2005-03-31
Medium Priority
Last Modified: 2010-04-07
I want use a variable/parameter being passed in a query string which should always be present.. however if someone manually removes this or it is somehow not passed I want to redirect the person to another page.  The value of the variable is easy enough to get via Request.QueryString("sd") but how would I test if sd is present in the query string.  I know there are methods to count the number of variables in the query string but I want to test specifically for the presence or lack there of for sd.
Question by:egdigital
  • 2
  • 2
LVL 20

Expert Comment

ID: 13678287
A simple checking condition as shown below will do the job

If Request.QueryString("sd") Is Nothing Then
   ' sd is not present
End If


Author Comment

ID: 13722168
Does this apply to:

1. page1.aspx?sd=122222  (Is not nothing)
2. page1.aspx?sd=   (Is nothing?)
3. page1.aspx (how does that code handle this scenario?)

LVL 20

Accepted Solution

ihenry earned 200 total points
ID: 13723187
1. yes
2. yes
3. Request.QueryString.Count = 0

Author Comment

ID: 13723204
Great, thanks ihenry

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question