getting query info in a url

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

ASP.NET 2.0

I'm wondering how I can get a specific parameter in the query string in a
url. I have this url in my website:
Default.aspx?mode=1 So I'm wondering how I can the "mode" parameter and its
value.

I've seached the documentation I came across Uri.Query which returns the
entire query list in one single string (that is how I understand it). What
I'm looking for is method/property which returns the parameters as a
collection (name/value collection)

Any suggestions?
 
Strange but just a few seconds after posting this question I came across
what I was looking for:
HttpRequest.QueryString
 
I'm wondering how I can get a specific parameter in the query string in a
url. I have this url in my website:
Default.aspx?mode=1 So I'm wondering how I can the "mode" parameter and
its value.

Multiple ways:

1. Request.QueryString["mode"]
2. Request["mode"]

However, note that while doing Request["mode"], we are looking at various
places at one go:
1. QueryString
2. Form-Data
3. Cookies
4. Headers


--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------
 
Just to help you bit more. Request is an namevaluecollection object in
asp.net and represents a set of objects you can query. As a collection it
can be iterated

The QueryString you have found on your own but there are other properties of
the request object that are equally useful, such as the Form,
ServerVariables, and Cookie collections.

Its worth reading a little about page execution to learn where various
elements become exposed.
http://msdn2.microsoft.com/en-us/library/aa479007.aspx

--
--
Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
 
Back
Top