473,804 Members | 3,462 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to know a Request.Param value is numeric type or not?

How can I understand a Request.Params object's type?

I need this:
User enters www.domain.com/myfile.aspx?6
then myfile.aspx.cs use
"SELECT name FROM people WHERE id="+Request.Pa rams[0];

so if the user enters the parameter as string instead of integer:
www.domain.com/myfile.aspx?test

the page fails!

How can I prevent this? I think I should analize the first param's type but
how?

Thanks in advance

E.T.
Nov 16 '05 #1
3 3663
try
{
int id = int.Parse(Reque st.Params[0]);
// continue with your sql processing
}
catch
{
// show an error message
}

-Jason

2003et wrote:
How can I understand a Request.Params object's type?

I need this:
User enters www.domain.com/myfile.aspx?6
then myfile.aspx.cs use
"SELECT name FROM people WHERE id="+Request.Pa rams[0];

so if the user enters the parameter as string instead of integer:
www.domain.com/myfile.aspx?test

the page fails!

How can I prevent this? I think I should analize the first param's type but
how?

Thanks in advance

E.T.

Nov 16 '05 #2
oh right...

Thank you

"Jason DeFontes" <ja***@defontes .com> wrote in message
news:uo******** ******@TK2MSFTN GP12.phx.gbl...
try
{
int id = int.Parse(Reque st.Params[0]);
// continue with your sql processing
}
catch
{
// show an error message
}

-Jason

2003et wrote:
How can I understand a Request.Params object's type?

I need this:
User enters www.domain.com/myfile.aspx?6
then myfile.aspx.cs use
"SELECT name FROM people WHERE id="+Request.Pa rams[0];

so if the user enters the parameter as string instead of integer:
www.domain.com/myfile.aspx?test

the page fails!

How can I prevent this? I think I should analize the first param's type but how?

Thanks in advance

E.T.

Nov 16 '05 #3
And if a user enters:
www.domain.com/myfile.aspx?1;DROP DATABASE master

the page will really fail. ;)
"SELECT name FROM people WHERE id="+Request.Pa rams[0];

2003et wrote:
oh right...

Thank you

"Jason DeFontes" <ja***@defontes .com> wrote in message
news:uo******** ******@TK2MSFTN GP12.phx.gbl...
try
{
int id = int.Parse(Reque st.Params[0]);
// continue with your sql processing
}
catch
{
// show an error message
}

-Jason

2003et wrote:
How can I understand a Request.Params object's type?

I need this:
User enters www.domain.com/myfile.aspx?6
then myfile.aspx.cs use
"SELECT name FROM people WHERE id="+Request.Pa rams[0];

so if the user enters the parameter as string instead of integer:
www.domain.com/myfile.aspx?test

the page fails!

How can I prevent this? I think I should analize the first param's type
but
how?

Thanks in advance

E.T.


Nov 16 '05 #4

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

Similar topics

5
2038
by: Alexandre | last post by:
Hi, Im a newb to dev and python... my first sefl assigned mission was to read a pickled file containing a list with DB like data and convert this to MySQL... So i wrote my first module which reads this pickled file and writes an XML file with list of tables and fields (... next step will the module who creates the tables according to details found in the XML file). If anyone has some minutes to spare, suggestions and comments would be...
15
3250
by: lawrence | last post by:
Sorry for the dumb question but I'm new to Javascript. I wrote this script hoping to animate some div blocks on a page. You can see the page here: http://www.keymedia.biz/demo.htm Can anyone tell me why these DIVs don't drift to the left as they are supposed to? <script language="javascript">
2
1394
by: Thomas Magma | last post by:
Hello, I have an application that generates a HTML document that contains an applet. It places raw data into the PARAM NAME tag. Well, once in a blue moon it places the numeric character reference &# into the data. When my Java applet imports this using the getParameter command, it reacts differently between different version of IE. One solution is to not let my original application generate the sequence &#, however, this does not fix...
6
6942
by: Peter Row | last post by:
Hi, I am writing a DLL in VB.NET that implements IHttpHandler.ProcessRequest. This code calls a sub and I need to know if that sub did a response redirect or not. Specifically I need to know that either the sub did a redirect or a specific value was specified in the URL. If neither a redirect was done and a certain value was
0
1090
by: Fao, Sean | last post by:
I recently had the desire to create a CheckBoxColumn (similar to a ButtonColumn) that I could add to a DataGrid. I believe the 2.0 framework already includes such a type; however, this is for an ASP.NET 1.1 project. Could anybody please give me some feedback on my implementation? <code> using System; using System.Web.UI;
13
12415
by: trpost | last post by:
I am looking to make a small web app that will return the status of a website from the client browser. I tried this with AJAX and it worked great locally, but did not work for remote users accessing the page, I ran into the security problem with making a cross domain request. I have been reading that with JSON a cross domain request can be accomplished, but have not been able to find any examples on how to use it or how to get the return...
11
1905
by: Bob Altman | last post by:
Hi all, I want to write a generic class that does this: Public Class X (Of T) Public Sub Method(param As T) dim x as T = param >3 End Sub End Class
0
2926
by: buntyindia | last post by:
Hi, I have a very strange problem with my application. I have developed it using Struts. I have a TextBox With Some fixed value in it and on Submit iam passing it to another page. <html:form action="/login"> <html:text property="userName" value="Bunty"/> <html:submit/>
1
1724
by: Frank van Bortel | last post by:
R.H. Nadorp wrote: Could it be you NLS_LANG settings expect a "," as numeric separator? Try to make the NLS_NUMERIC_CHARACTERS to be the same at both (client, server) sides, use an alter session statement to force/test this. -- Regards,
0
10589
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10327
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7625
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
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 we have to send another system
2
3828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.