473,287 Members | 1,813 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,287 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 6927


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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.