"Danny Vucinec" <Da**********@discussions.microsoft.comwrote in message
news:B8**********************************@microsof t.com...
Hi,
I've a problem reading querystring parameters that are 'uri encoded'.
Anyone
has a solution for this?
To reproduce the problem, create a classic ASP containing the following
code:
>
-----------------------
<p>Value sent via querystring: <%=
Server.HTMLEncode(Request.QueryString("value")) %></p>
<input id="input" />
<button id="submit" onclick="window.location.assign('Test.asp?value=' +
encodeURIComponent(input.value));">submit</button>
-----------------------
Now, enter the value "Dré" and submit. The page will show the value
"Dré",
but I except Request.QueryString("value") to return the original value,
i.e.
"Dré".
encodeURIComponent correctly encodes using UTF-8 character codes.
Unfortunately IE would incorrectly allow the query portion of a URL to be
sent using whatever local encoding is being used. IIS 5 and 6
correspondingly expect the query portion to be encoded to match the sessions
codepage.
Hence using encodeURIComponent to encode a string into the query generates a
correctly encoded URL which IIS mis-reads.
Use Response.Codepage = 65001 to allow ASP to correctly read the URL.
However unless you reset Response.Codepage to it's original value before
sending any output you will need to ensure you set Response.CharSet =
"UTF-8" and save the page as UTF-8. You will also need to ensure any pages
receiving form posts from the page also have Codepage set to 65001 before
attempting to read the form values.
--
Anthony Jones - MVP ASP/ASP.NET