catch not valid value in the querystring, how??

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