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

Discussion in 'ASP .Net' started by =?Utf-8?B?UGV0ZXIy?=, May 16, 2006.

  1. 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
     
    =?Utf-8?B?UGV0ZXIy?=, May 16, 2006
    #1
    1. Advertising

  2. 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/
     
    Martin Honnen, May 16, 2006
    #2
    1. Advertising

  3. Re: Encoding problem when posting text between classic ASP and ASP

    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/
    >
     
    =?Utf-8?B?UGV0ZXIy?=, May 16, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VG9ueQ==?=

    Session Variables between ASP Classic and ASP .NET

    =?Utf-8?B?VG9ueQ==?=, Jan 22, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    5,442
  2. =?Utf-8?B?Um9iIFNob3JuZXk=?=

    asp.net posting to classic asp problem.

    =?Utf-8?B?Um9iIFNob3JuZXk=?=, Sep 23, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    3,665
    Steven Cheng[MSFT]
    Sep 24, 2004
  3. Guest
    Replies:
    1
    Views:
    901
    Kevin Spencer
    May 19, 2005
  4. Replies:
    8
    Views:
    920
    mhylden
    Nov 10, 2006
  5. =?Utf-8?B?Q2hyaXMgTGFuZQ==?=

    How to Share Session State Between Classic ASP and ASP.NET

    =?Utf-8?B?Q2hyaXMgTGFuZQ==?=, Oct 4, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    1,021
    =?Utf-8?B?Q2hyaXMgTGFuZQ==?=
    Oct 4, 2007
Loading...

Share This Page