473,513 Members | 2,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

catch not valid value in the querystring, how??

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
Apr 27 '07 #1
2 1338
Take a look at int.TryParse.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Jeff" wrote:
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
Apr 27 '07 #2
Jeff wrote:
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.

--
Göran Andersson
_____
http://www.guffa.com
Apr 27 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
10195
by: Lisa | last post by:
I have a drop down that defaults to "select" after the page refreshes. How do I keep the selected value in the dropdown field... I've tried EVERYTHING and nothing works! :( <script...
1
8728
by: PT | last post by:
I got a problem. And thats..... First of all, I got these three tables. ------------------- ------------------ ---------------------- tblPerson tblPersonSoftware ...
4
16955
by: Todd Perkins | last post by:
Hello all, surprisingly enough, this is my first newsgroup post, I usually rely on google. So I hope I have enough info contained. Thank you in advance for any help! Problem: I am getting...
3
2511
by: catweezle2010 | last post by:
Hello NG, I have three files (default.aspx, search.aspx and work.aspx). The way is: login on default (if session is newsession). The loginname I write into as sessionvariable (username). So I...
3
7069
by: William Mild | last post by:
I am porting old Dreamweaver generated ASP code to ASP.NET (VBScript to VB.NET). Error: Cast from type 'Field' to type 'Integer' is not valid The error occurs on the line which says "rsStudents =...
6
1776
by: Joe | last post by:
Hello All: I have a webform (WebForm1.aspx) that retrieves a value from a database (_formSessionId) the first time that it is posted. After the user filles in the form, he/she clicks a Button...
6
16222
by: Mehdi | last post by:
Hi, I get the following URL on page load: http://www.server1.com?RedirectUrl=http://www.server2.com?id=777 So QueryString will return (after cleaning up via URL Encode/decode) :...
11
4617
by: Tantr Mantr | last post by:
I want to convert a string to a DateTime type. The user can enter the date in various formats and I am not sure if it will be a valid Date. Is it possible to check if a string can be converted to a...
0
1287
by: =?Utf-8?B?RGF2aWQ=?= | last post by:
I need to convert an incoming byte array to a Unicode string, when (if) that byte array contains valid Unicode values (sometimes it doesn't). I've been trying to use...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7160
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5685
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1594
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.