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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month8 days, 20 hours left to enroll

764 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