473,396 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

querystring parameters

Hi all,

If I am reading this right, then the querystring parameters must be "&"
and not "&". However, IIS 6.0 and asp.net request.querystring fails to
capture the values if "&" is specified. e.g.
http://myserver/test.aspx?pid=1&did=2

http://www.w3.org/TR/html401/appendi...s.html#h-B.2.2

Any ideas?
Nov 23 '06 #1
4 9468
<pa***@community.nospamwrote in
news:#D**************@TK2MSFTNGP03.phx.gbl:
Hi all,

If I am reading this right, then the querystring parameters must be
"&amp;" and not "&". However, IIS 6.0 and asp.net request.querystring
fails to capture the values if "&amp;" is specified. e.g.
http://myserver/test.aspx?pid=1&amp;did=2

http://www.w3.org/TR/html401/appendi...s.html#h-B.2.2

Any ideas?
QueryString parameters are separated by &, not &amp. If you have an
ampersandin a variale, it must be &amp;. If you use ampersands ina
variable, you have to unencode afterwards.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*************************************
Think Outside the Box!
*************************************
Nov 23 '06 #2
Thanks for Gregory's input.

Hello Param,

I think this problem you met is related to the html url encoding.

Yes, you're right that there are some particular characters that must be
encoded when being embeded in url string(in the querystring value). This
is because there are some chars which has their reserved usage. for
example, as a typical url with querystring as below:

http://website/app/test.aspx?id=xxxx&name=xxxx

The "&" and "=" character has their particular usage in querystring (to
separate multi querystring items and separate key and value of each item).
Thus, when such characters occur in our querystring item's value, we need
to escape them.

However, the escape format for url string is not like the one you
mentioned:

&---&amp; (this is used in XML/HTML document's character escaping)

but like:

&---- %26

because URL encoding rule will escape the original characeter to their hex
value (with a % preceding ). So for the above example, if the "name"
parameter's value contains a "&" char, the escaped (after url encoding) url
will look like:

http://website/app/test.aspx?id=xxxx&name=xx%26xx

Here is an article introducing url encoding

#INTRODUCTION TO URL ENCODING
http://www.permadi.com/tutorial/urlEncoding/

#HTML URL-encoding Reference
http://www.w3schools.com/tags/ref_urlencode.asp

Actually, you can even url encode every ascii char in the querystring value
(through this is not necessary). For example, if you use the following url

http:/....../urlstringpage.aspx?name=%26%41%42%43

the server-side component (such as ASP.NET ) can correct decode the value
and get the original querystring:

name= &ABC

If there is anything unclear, please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 23 '06 #3
Steve, I understand what u r trying to say. So why does this article say
otherwise:

http://www.w3.org/TR/html401/appendi...s.html#h-B.2.2

Clearly it shows and recommends using "&amp;" as the querystring item
seperator.

Am I missing something? I have a 3rd party partner that is trying to link
into our system and will not budge on this. He claims that he is standards
compliant, but the link doesnt work on my end i.e. my .aspx can never
retrieve his url parameters.

TIA!
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:EZ**************@TK2MSFTNGXA01.phx.gbl...
Thanks for Gregory's input.

Hello Param,

I think this problem you met is related to the html url encoding.

Yes, you're right that there are some particular characters that must be
encoded when being embeded in url string(in the querystring value). This
is because there are some chars which has their reserved usage. for
example, as a typical url with querystring as below:

http://website/app/test.aspx?id=xxxx&name=xxxx

The "&" and "=" character has their particular usage in querystring (to
separate multi querystring items and separate key and value of each item).
Thus, when such characters occur in our querystring item's value, we need
to escape them.

However, the escape format for url string is not like the one you
mentioned:

&---&amp; (this is used in XML/HTML document's character escaping)

but like:

&---- %26

because URL encoding rule will escape the original characeter to their hex
value (with a % preceding ). So for the above example, if the "name"
parameter's value contains a "&" char, the escaped (after url encoding)
url
will look like:

http://website/app/test.aspx?id=xxxx&name=xx%26xx

Here is an article introducing url encoding

#INTRODUCTION TO URL ENCODING
http://www.permadi.com/tutorial/urlEncoding/

#HTML URL-encoding Reference
http://www.w3schools.com/tags/ref_urlencode.asp

Actually, you can even url encode every ascii char in the querystring
value
(through this is not necessary). For example, if you use the following url

http:/....../urlstringpage.aspx?name=%26%41%42%43

the server-side component (such as ASP.NET ) can correct decode the value
and get the original querystring:

name= &ABC

If there is anything unclear, please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Nov 23 '06 #4
Thanks for your quick reply Param,

Yes, the document you refered is correct, and actually what the document
stated and what I mentioend in the last reply aims at different context.
The W3C document you refer to is targeting the "&" character in a SGML or
(commonly a xml/html document). That means, when we put a url in an
SGML/XML/HTML document and the document contains "&" in the url
querystring, you can either use "&" directly or use the "&amp;" format.

For html web page, if you use the following style url:

<A href="http://host/?x=1&amp;y=2">

the webbrowser will help you translate it into the following one when send
http request to the linked resource:

http://host/?x=1&y=2

so in http request message, the querystring separater must be "&" (hex
value 26) rather than "&amp;"

"&amp;" is used in html page's content only. You can also use some TCP or
http trace utility to capture the http request message to verfiy this.

In other word, in html/xhtml webpage, you can use either "&amp;" or "&" as
the querystring separater, however, if you directly input the url in
browser's address bar or use other network component to send http request,
you should use "&" for querystring separator(or the %26 urlencoded
format) rather than the "&amp;" style.

Hope this clarify it further. Please feel free to let me know if you have
any other questions.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 23 '06 #5

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

Similar topics

5
by: Mike | last post by:
Is it possible to loop round all querystring parameters in a web page (i.e. access them without hardcoding them)? I want to do this because I have a page that has different querystring variables...
1
by: andrew_martin | last post by:
I have another newbie xml/.net question. All apologies. I'm trying to get an aspx file to modify an XSLT file based on a querystring. ie. recipe.aspx?recipe=cheesecake will add this line to the...
4
by: DaveF | last post by:
I am looping threw the querySting with: foreach (string name in Request.QueryString) I have a problem with a '&' being in one of the values. How do I deal with this? ...
3
by: Nobody | last post by:
Hi -- I'm developing an ASP.NET application in VS.NET and I want the startup page to read in some parameters from a querystring. But I can't figure out where to set the querystring. I thought it...
5
by: Vishwanathan Raman | last post by:
I have only one page.Its a search results page.Depending on the component selected in the results page the search is initiated. I am using QueryString to send me details pertinent to search.But I...
8
by: tshad | last post by:
How do you check to see if there is no query string? I could have: 1) file.aspx 2) file.aspx?r=5&st=joe I need to know when there is no query string at all (1). Thanks,
1
by: Adeel Ahmad | last post by:
Hi, The subject sounds confusing but here is what i want to do. I have a button on my page which says...
5
by: Nirmal Singh | last post by:
I am a newbie trying to learn ASP.net 2.0. I want to retrieve the QueryString and process it to produce some parameters. I then want to redirect the user to another page, passing these...
0
by: mohaaron | last post by:
Hello all, I'm having a problem using the ReturnUrl parameter while using FormsAuthentication. If I already have some querystring parameters in the url like this. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...
0
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...
0
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,...

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.