Check for Parameters from Query String

IT_Help

Member
Joined
May 17, 2009
Messages
8
Programming Experience
Beginner
Hi

i have a page that displays an image based on the parameter value coming from the previous page.
i want to restrict the user from manually manupulating the query string and user should not be able to view the page
eg
i have a page that should always have a URL as
www.abc.com/image.aspx?id=87654

now i want that user shuld not be able to access the page as
www.abc.com/image.aspx

Presently when i hit the above URL it gives the .net application error which i dont want. The user should be redirected to some defined error page
 
Hi All
I just figured out a way.
I am doing exception handling for System.NullRefrenceException.
as soon as someone hits the URL, without the parameter the page throws Null refrence exception as parameter is not there.
So I am catching this exception and redirecting it to the standard error page in the Application
 
It is better if the Exception don't happen.
VB.NET:
If Request.QueryString.Count = 0 Then
    Response.Redirect("Errors.aspx")
End If
 
Hi John

Thanks for your reply.
i think this count = 0 will check for value of parameter.
but what if the parameter itself is not there.

i am already doing something similar to your response like

If parameter = Nothing Then
Response.Redirect("../Web/Error.aspx?Error=Parameter Value is Empty")
End If
 
No, it checks how many query string pairs is in the collection, 0 means zero items in the collection.
 
Back
Top