By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,478 Members | 1,833 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,478 IT Pros & Developers. It's quick & easy.

Encoding problem when posting text between classic ASP and ASP.NET

P: n/a
Hi,
I have a problem posting non-ASCII characters in FORM fields between classic
ASP and ASP.NET. I use a fully patched Windows 2000 Advanced Server with .net
2.0 and visual Studio 2005 installed, IIS, IE6 etc ...

When an *.ASPX page receives the post, it drops non-ASCII characters, for
example it drops character é from word Montréal. Specifying explicit encoding
on ASP/ASPX page doesn't help. The encoding works without doing anything
special when posting same text from an ASPX to another ASPX page.

Here are two simple ASP and ASPX pages to reproduce the problem, located on
IIS in same folder:

-------------------------------------------------
test_asp.asp (just post something to ASPX)
-------------------------------------------------
<html><head><title>Classic ASP page</title></head><body>
Posting this: Montréal<br>
<form method="post" action="test_aspx.aspx">
<input name="test" value="Montréal" type="text"/>
<input type="submit" value="Post to ASPX">
</form>
</body></html>

------------------------------------------------------------
test_aspx.aspx (display what was received from ASP)
------------------------------------------------------------
<%@ Page Language="VB" %>
<html><body>
Expecting: Montréal<br>
<form method="post">
Received: <input name="test" value="<%=Request.Form("test")%>"/><br>
<input type="submit" value="Post to ASPX">
</form>
</body></html>
POST Montréal from ASP to ASPX => doesn't work (drops é character)
POST Montréal from HTML to ASPX => doesn't work
POST Montréal from/between ASP/HTML to anything else => OK
POST Montréal from ASPX to ASPX => OK

Any help is appreciated.

Thanks
Peter

May 16 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a


Peter2 wrote:

POST Montréal from ASP to ASPX => doesn't work (drops é character)
POST Montréal from HTML to ASPX => doesn't work


ASP.NET has a setting for the request encoding in the web.config, see
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gngrfGlobalizationSection.asp>
If the 'é' gets lost then the encoding the browser uses the encode the
characters is different from the encoding ASP.NET uses to decode
incoming data. So you either need to change the encoding of the classic
ASP and static HTML pages (to for instance UTF-8) as that way the
browser then encodes the data with UTF-8 or you need to change the
setting for ASP.NET to that encoding the data is sent with.

Additionally there is an attribute accept-charset for HTML form
elements, see
<http://www.w3.org/TR/html4/interact/forms.html#adef-accept-charset>
which browser like Mozilla or Opera supports as far as I remember so
there doing e.g.
<form method="POST"
accept-charset="UTF-8"
action="form.aspx">
could help solve the problem (of course if the accept-charset matches
the ASP.NET requestEncoding setting, the UTF-8 in my sample code is just
an example).

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
May 16 '06 #2

P: n/a
Thanks Martin,
creating a web.confg file and a globalization entry in it with iso-8859-1
encoding did help, without doing any changes to ASP or ASPX files.

regards
Peter

"Martin Honnen" wrote:


Peter2 wrote:

POST Montréal from ASP to ASPX => doesn't work (drops é character)
POST Montréal from HTML to ASPX => doesn't work


ASP.NET has a setting for the request encoding in the web.config, see
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gngrfGlobalizationSection.asp>
If the 'é' gets lost then the encoding the browser uses the encode the
characters is different from the encoding ASP.NET uses to decode
incoming data. So you either need to change the encoding of the classic
ASP and static HTML pages (to for instance UTF-8) as that way the
browser then encodes the data with UTF-8 or you need to change the
setting for ASP.NET to that encoding the data is sent with.

Additionally there is an attribute accept-charset for HTML form
elements, see
<http://www.w3.org/TR/html4/interact/forms.html#adef-accept-charset>
which browser like Mozilla or Opera supports as far as I remember so
there doing e.g.
<form method="POST"
accept-charset="UTF-8"
action="form.aspx">
could help solve the problem (of course if the accept-charset matches
the ASP.NET requestEncoding setting, the UTF-8 in my sample code is just
an example).

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

May 16 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.