Re: Why is ASP.NET changing character encoding of documents?



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=http%3A%2F%2Fasp.net.do%2Ftest%2Fw3cvalidate.aspx&charset=%28detect+automatically%29&doctype=Inline&ss=1&outline=1&sp=1&No200=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" <nomailreplies@xxxxxxxxxxx> wrote in message
news:e0t2Fhq0FHA.1040@xxxxxxxxxxxxxxxxxxxxxxx
> 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=http%3A%2F%2Fasp.net.do%2Ftest%2Fw3cvalidate.aspx&charset=%28detect+automatically%29&doctype=Inline&ss=1&outline=1&sp=1&No200=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" <jjjj@xxxxxxxxxxxx> wrote in message
> news:s5tc86sgwguh.26hlay83zebx.dlg@xxxxxxxxxxxxx
>>
>> 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
>
>


.



Relevant Pages

  • Re: Character encoding
    ... a lot of editors allow to choose the text encoding ... that in my html code i have to set manually. ... There is a little confusion here: the way a text editor encore the ... HTML can contain a meta tag that specifies the encoding, ...
    (Fedora)
  • Re: requestEncoding = "ISO-8859-1"
    ... I placed the META tag in the HTML form file. ... Sorry - how does one encode them physicially using UTF-8 ... I need to pick an encoding that is capable of representing the character 'ö' like UTF-8 or ISO-8859-1. ... But of course one thing always remains true: You must not declare in your HTML page's META tag an encoding that's different from the one you used to save the file. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: requestEncoding = "ISO-8859-1"
    ... "Mark" is far to bland. ... I placed the META tag in the HTML form file. ... I need to pick an encoding that is capable of representing the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: requestEncoding = "ISO-8859-1"
    ... I placed the META tag in the .html page, not the .aspx page, and this ... UTF-8 into the meta tag of every form our staff creates? ... browser assumes ISO-8859-1 by default (check your browser's encoding ... HTML 4.01 even includes an attribute to specify the character encoding ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Where to get BeautifulSoup--www.crummy.com appears to be down.
    ... Beautiful Soup uploaded to my website: ... obtaining a sensible parse tree in the face of common HTML errors. ... the encoding of an HTML or XML document, ... appears after this Tag in the document.""" ...
    (comp.lang.python)