QueryString Parameter Substitution

G

Guest

ASP.net Framework 2 IIS 6 Win 2003

Is it possible to substitute the & (ampersand) in a querystring for antother
value i.e

test.com?param1=test;param2=notest

instead of &(ampersand) can i use ; (semicolon)
 
K

Karl Seguin [MVP]

According to the URI RFC, ; is an allowed separator. According to W3C
standards, it's recommended for browsers to support ; as well incase the
author needs a lot of & they don't want to encode
(http://www.w3.org/TR/1999/REC-html401-19991224/appendix/notes.html#h-B.2.2)

Looking inside the .NET framework, the parser seems to have '&' hardcoded.
So you'll need to write your own. A simple version might just use the Split
function:

if (Request.Url.Query.Length > 0)
{
string parts[] = Request.Url.Query.Substring(1,
Request.Url.Query.Length-1).Split(';', '&');
//loop through parts and dump it into your own NameValueCollection if
you want..
}

Karl
 
K

Karl Seguin [MVP]

I posted a more complete solution at:
http://codebetter.com/blogs/karlseguin/archive/2006/05/04/144052.aspx

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:%[email protected]...
According to the URI RFC, ; is an allowed separator. According to W3C
standards, it's recommended for browsers to support ; as well incase the
author needs a lot of & they don't want to encode
(http://www.w3.org/TR/1999/REC-html401-19991224/appendix/notes.html#h-B.2.2)

Looking inside the .NET framework, the parser seems to have '&' hardcoded.
So you'll need to write your own. A simple version might just use the
Split function:

if (Request.Url.Query.Length > 0)
{
string parts[] = Request.Url.Query.Substring(1,
Request.Url.Query.Length-1).Split(';', '&');
//loop through parts and dump it into your own NameValueCollection if
you want..
}

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top