Request.QueryString

  • Thread starter Thread starter shapper
  • Start date Start date
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
 
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
 
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
 
Back
Top