PDA

View Full Version : Quick question regarding Request


[o_O]
12-13-2002, 10:17 PM
If i had a page which is to check for a few variables but these variables could come via Querystring or Form how should the check be done? I would have to put:


If Request.Form("variable1") <> "" Then
..
End If

Request.Querystring("variable1") <> "" Then
..
End if


the variable would be the same and have the same value just passed differently.

Is there a way to combine the two? check for both at once



Someone suggested just using Request("variable") but doesn't this sift through all four Request collections: Request.Form, Request.QueryString, Request.Cookies, Request.ServerVariables and therefore slow performance





:confused:

whammy
12-13-2002, 11:23 PM
You could check for the REQUEST_METHOD and then check depending on that... i.e.:

If Request.ServerVariables("REQUEST_METHOD") = "GET" Then
variable1 = Request.QueryString("variable1")
variable2 = Request.QueryString("variable2")
Else
variable1 = Request.Form("variable1")
variable2 = Request.Form("variable2")
End If


Otherwise, as far as I know, you'd have to just query the request collection which would entail running through all of them.

However, either way I doubt it would affect performance much, if at all - but I could be wrong. Haven't tried it. :D

[o_O]
12-14-2002, 04:54 AM
o.k :)