Request.QueryString

S

shapper

Hello,

I am requesting a parameter from the query string using:
Dim id As String = Request.QueryString("id")

The problem is that I get an error if the parameter does not exist.
Is there a way to solve this?

Thanks,
Miguel
 
G

Guest

Sure. you should make a habit of always checking for null before attempting
to use an object. In VB.NET (not my preferred language!):

Dim xyz as String = String.Empty
If Request.QueryString("blah") is Not Nothing then
xyz = Request.Querystring("blah")
End if

Cheers,
Peter
 
S

Steve C. Orr [MVP, MCSD]

Something like this should do the trick:

Dim id As String = ""
If Request.QueryString("id") IsNot Nothing Then
id = Request.QueryString("id").ToString()
End If
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top