473,323 Members | 1,550 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,323 software developers and data experts.

Why is ASP.NET changing character encoding of documents?


The below html validates correctly on w3.org's html validator when the file
has an html extension. When the same file gets an aspx extension, I get the
error below from the validator. This tells me that ASP.NET is changing the
character encoding in the http header. How can this be corrected so that
aspx pages validate correctly?

Error Message:
"The character encoding specified in the HTTP header (utf-8) is different
from the value in the <meta> element (iso-8859-1). I will use the value
from the HTTP header (utf-8) for this validation."
html file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>

--
John Dalberg
Nov 19 '05 #1
2 2325
That's really strange.

When I check : http://asp.net.do/test/w3cvalidate.aspx
which has the *exact* same content as you provided
( I copied and pasted it ) it passes validation, and the
encoding is reported as iso-8859-1.

Here's the check URL :

http://validator.w3.org/check?uri=ht...00=1&verbose=1

What gives, John ?

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"John Dalberg" <jj**@hotmail.com2> wrote in message
news:s5***************************@40tude.net...

The below html validates correctly on w3.org's html validator when the file
has an html extension. When the same file gets an aspx extension, I get the
error below from the validator. This tells me that ASP.NET is changing the
character encoding in the http header. How can this be corrected so that
aspx pages validate correctly?

Error Message:
"The character encoding specified in the HTTP header (utf-8) is different
from the value in the <meta> element (iso-8859-1). I will use the value
from the HTTP header (utf-8) for this validation."
html file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>

--
John Dalberg

Nov 19 '05 #2
I found out what gives.

My default encoding in web.config was iso-8859-1.

When I run that page with
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
both charsets are the same, so everything is OK.

When I change web.config to use utf-8, I get the same error you reported,
but all that means is that you cannot override an asp.net charset setting
with a META tag.

The web.config setting takes precedence over the meta tag.

In sum, if you want to change the web.config setting ( or the
default setting for asp.net, which is utf-8 ), use the @Page directive :

<%@ Page ResponseEncoding="iso-8859-1" %>
and get rid of the META tag you tried to use.

Check the valid result, eliminating the META tag,
and using the above @Page setting, with the default
encoding set to utf-8 in web.config.

http://validator.w3.org/check?uri=ht...00=1&verbose=1

best regards,

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:e0**************@TK2MSFTNGP14.phx.gbl...
That's really strange.

When I check : http://asp.net.do/test/w3cvalidate.aspx
which has the *exact* same content as you provided
( I copied and pasted it ) it passes validation, and the
encoding is reported as iso-8859-1.

Here's the check URL :

http://validator.w3.org/check?uri=ht...00=1&verbose=1

What gives, John ?

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"John Dalberg" <jj**@hotmail.com2> wrote in message
news:s5***************************@40tude.net...

The below html validates correctly on w3.org's html validator when the file
has an html extension. When the same file gets an aspx extension, I get the
error below from the validator. This tells me that ASP.NET is changing the
character encoding in the http header. How can this be corrected so that
aspx pages validate correctly?

Error Message:
"The character encoding specified in the HTTP header (utf-8) is different
from the value in the <meta> element (iso-8859-1). I will use the value
from the HTTP header (utf-8) for this validation."
html file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>

--
John Dalberg


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: David Komanek | last post by:
Hi all, I have a question if it is possible to manipulate the settings of character encoding in Ms Internet Explorer 5.0, 5.5 and 6.0. The problem is that the default instalation of Ms IE seems...
38
by: Haines Brown | last post by:
I'm having trouble finding the character entity for the French abbreviation for "number" (capital N followed by a small supercript o, period). My references are not listing it. Where would I...
76
by: Zenobia | last post by:
How do I display character 151 (long hyphen) in XHTML (utf-8) ? Is there another character that will substitute? The W3C validation parser, http://validator.w3.org, tells me that this character...
9
by: Safalra | last post by:
The idea here is relatively simple: a java program (I'm using JDK1.4 if that makes a difference) that loads an HTML file, removes invalid characters (or replaces them in the case of common ones...
7
by: Jeffrey Spoon | last post by:
Hello, I'm a bit stuck trying to convert a text file which contains extended ASCII text and changing the ASCII values so they become readable. I do this by subtracting 127 from the ASCII value....
4
by: Trapulo | last post by:
I've a webservice with a string parameter. I call this webservice passing a string that is 1129 chars length. On the webservice, the received string is 1146 length (I tested sizes with...
44
by: Kulgan | last post by:
Hi I am struggling to find definitive information on how IE 5.5, 6 and 7 handle character input (I am happy with the display of text). I have two main questions: 1. Does IE automaticall...
5
by: Timothy Madden | last post by:
Hello Is there a function that will allow me to output text written in utf-8 (from db for example) if my document has Content-Type: text/html; charset=ISO-8859-1 I mean htmlspecialchars()...
7
by: tempest | last post by:
Hi all. This is a rather long posting but I have some questions concerning the usage of character entities in XML documents and PCI security compliance. The company I work for is using a...
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
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.