473,406 Members | 2,343 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,406 software developers and data experts.

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

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
2 6954


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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

38
by: lawrence | last post by:
I'm just now trying to give my site a character encoding of UTF-8. The site has been built in a hodge-podge way over the last 6 years. The validator tells me I've lots of characters that don't...
2
by: jmhmaine | last post by:
During the course of development cycle I receive HTML files from designers that use Macs and PCs, but use tools other then Visual Studio. So these files sometimes are not UTF-8 Encoded. I see...
4
by: Mark | last post by:
Hi... Just noticed something odd... In old ASP if you had query parameters that were invalid for their encoding (broken utf-8, say), ASP would give you back chars representing the 8-bit byte...
6
by: Danny | last post by:
I am working on a project in which a number of client applications will be posting xml documents as a byte array to an ASP.NET page on our web server. I am trying to simulate the process and run...
0
by: Lotta P | last post by:
Hi, I have a problem concerning encoding when posting a form. The form (a textbox and a button) is posted using JavaScript and a window.location("http://therecieverofthedata"). The website...
4
by: Bob | last post by:
Hi Need to produce a Doc with no encoding info. Is there anyway of doing this? Thanks Bob i.e. <?xml version=\"1.0\" ?>
2
by: Alex Maghen | last post by:
I have created the world's simplest Code-Behind ASPX page in VS 2005. I've used all the defaults. But when I go to build and run the page, it comes up in Chinese (or some Asian character set). I've...
7
by: EmeraldShield | last post by:
We have an application that uses UTF8 everywhere to load / save / process documents. One of our clients is having a problem with BIG Encoded files being trashed after running through our app. ...
23
by: Allan Ebdrup | last post by:
I hava an ajax web application where i hvae problems with UTF-8 encoding oc chineese chars. My Ajax webapplication runs in a HTML page that is UTF-8 Encoded. I copy and paste some chineese chars...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.