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

G

Guest

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
 
M

Martin Honnen

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/d...s/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).
 
G

Guest

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
 

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,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top