tags:

views:

561

answers:

4

Hi,

I'm new to ASP.net, how can I read parameters passed from ASP.net page (http://website.com/index.aspx?id=12&nam=eee) I develop this in C#.

Any small example will be appreaciated, just something for me to start from.

Thanks,

A: 

They are available in Request.QueryString. This is a collection of string key/value pairs, that can also be accessed by ordinal index.

ck
Thanks,But what I was looking for is small code example in C#
A: 

To complete the answer given above with an example:

int id = int.Parse(Request.QueryString["id"]);

Colin
+1  A: 

OK using your sample URL:

string id = Request.QueryString["id"];

string nam = Request.QueryString["nam"];

Read about Request.QueryString on MSDN. You probably want to convert the id value to an int.

RichardOD
A: 

For security reasons, be careful with XSS attacks. Please use this library:

http://msdn.microsoft.com/en-us/library/aa973813.aspx

Ex:

String Name = AntiXss.HtmlEncode(Request.QueryString["Name"]);

Efe Kaptan