473,659 Members | 3,348 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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><ti tle>Classic ASP page</title></head><body>
Posting this: Montréal<br>
<form method="post" action="test_as px.aspx">
<input name="test" value="Montréa l" 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="<%=Reque st.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 7022


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/gngrfGlobalizat ionSection.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.as px">
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/gngrfGlobalizat ionSection.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.as px">
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
2836
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 belong to the UTF-8 encoding. Other than changing them by hand, can anyone think of a clever way to find and convert these characters? http://validator.w3.org/check?uri=http%3A%2F%2Fwww.krubner.com%2F
2
4354
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 that Visual Studio creates a globalization tag with UTF-8 as the requestEndcoding and responseEncoding. I have three questions regarding this: 1. Does the globalization tag convert an ANSI encoded file into UTF-8 when it complies the ASPX and...
4
1609
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 value of the broken encoding, so you still got something for every input byte. This appears to have changed radically in ASP.Net, going down to the base System.Text.Encoding object. Now, it appears to simply vaporize bytes that don't fit in the...
6
1478
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 into problems. Sending code: ASCIIEncoding encoding = new ASCIIEncoding(); string lcUrl = "http://localhost/test/receive.aspx"; HttpWebRequest loHttp =
0
1401
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 have to be encoded in utf-8 (in my web.config I have <globalization requestEncoding="utf-8" responseEncoding="utf-8" />), but the reciever of the posted data have to get the data encoded in ISO-8859-1.
4
5555
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
2214
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 tried lots of stuff here and nothing seems to be working. Any ideas?
7
4471
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. Indeed I have verified that if I go to a website in Taiwan and save the file in BIG5 and then just load / save the file with a UTF8 text reader / write some bytes are modified. How can I correct this? It was my understanding the UTF8 was...
23
5009
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 from another HTML page viewed in IE7, that is also UTF-8 encoded (search for "china" on google.com). I paste the chineese chars into a content editable div. My Ajax webservice compiles an XML where the data from the content editable div is...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8747
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8627
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6179
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.