Request object does not handle globalization?

M

Mark

Assume you have a simple HTML form that submits its form results to a .aspx
page. The receiving .aspx page processes the values sent by the form. If
the form data contains an accented character (ex., Ángel with an accent over
"A"), the REQUEST object appears to loose the globalization, and nukes any
extended ascii characters. Is there a way to avoid this? In the examples
below, the resulting string is "ngel", without the A and accent.
Suggestions?

string myKey = "Name";
string Test0 = Request.Form.Get(myKey);
string Test1 = Request[myKey];
string Test2 = Request[myKey].ToString(CultureInfo.CurrentCulture);
string Test3 = Request[myKey].ToString(CultureInfo.InvariantCulture);

In the web.config, all the defaults remain including:
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />

For those of you wondering why we do this, we have non-technical staff
members that create HTML forms. They all redirect to a .NET application
that handles the routing/logging in a consistent way. However, it appears
to be dropping all extended ascii characters. Neat.
 
S

Steven Cheng[MSFT]

Hello Mark,

Welcome to the ASPNET newsgroup.

From your description, I understand you have some normal html pages which
will post some text data to some other ASP.NET web pages. The posted text
data contains some non-ascii chars and you found that those chars are not
handled correctly in the asp.net web pages, correct?

Based on my experience, this problem is likely caused by the html form text
data (sent to the asp.net page) is not encoded as utf-8 charset encoding.
For the ASP.NET web pages, since the web.config file has configured
request/response to use utf-8 encoding, if other charset/encoding text is
posted, the asp.net runtime will fail to correctly parse them.

What's the client machine's system locale setting, generally this will
affect the html page's text encoding because html or other text file is
saved as local machine's system locale's encoding(charset). Also, I suggest
you save that test html page as "utf-8" through notepad or any other text
editor and retest it in browser to see whether it can correctly post those
non-asscii chars to asp.net page.

If there is anything unclear or if you have any other question, please feel
free to let me know.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top