catch not valid value in the querystring, how??

J

Jeff

ASP.NET 2.0

Below you see the signature of a method in my webproject. "int user" get its
value from the "user" parameter in the querystring. The problem is that I'm
wondering how I can make a check in the code to catch if someone are trying
to send in a string value in the "user" parameter.... I assume a try/catch
block is ideal... But are wondering what Exception class to use??

public static Boolean Authenticate(int user) {
}

Any suggestions?

Jeff
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Jeff said:
ASP.NET 2.0

Below you see the signature of a method in my webproject. "int user" get its
value from the "user" parameter in the querystring. The problem is that I'm
wondering how I can make a check in the code to catch if someone are trying
to send in a string value in the "user" parameter.... I assume a try/catch
block is ideal... But are wondering what Exception class to use??

public static Boolean Authenticate(int user) {
}

Any suggestions?

Jeff

Use the int.TryParse method to parse a string that might not contain the
representation of a number.
 

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

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top