G
George
I am trying to check whether a query string is being passed to my .aspx page, like so:
If Not Request.QueryString Is Nothing Then
If CInt(Request.QueryString.GetValues("values")(0)) <> 1 Then
Response.Redirect("../somepage.htm")
End If
Else
Response.Redirect("../somepage.htm")
End If
If there is a query string, everything is fine, but when there isn't one, the app crashes on the
second line :
If CInt(Request.QueryString.GetValues("values")(0)) <> 1 Then
:with this error:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an
object.
What I don't understand, is why is it getting passed this line anyway:
If Not Request.QueryString Is Nothing Then
:when there wasn't even a query string passed? Why didn't it jump down to the Else part, instead?
Thanks,
George
If Not Request.QueryString Is Nothing Then
If CInt(Request.QueryString.GetValues("values")(0)) <> 1 Then
Response.Redirect("../somepage.htm")
End If
Else
Response.Redirect("../somepage.htm")
End If
If there is a query string, everything is fine, but when there isn't one, the app crashes on the
second line :
If CInt(Request.QueryString.GetValues("values")(0)) <> 1 Then
:with this error:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an
object.
What I don't understand, is why is it getting passed this line anyway:
If Not Request.QueryString Is Nothing Then
:when there wasn't even a query string passed? Why didn't it jump down to the Else part, instead?
Thanks,
George