confused over utf-8 encoding

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

I wish my aspx pages to be interpreted as UTF-8 by browsers.

Apart from setting the following in the web.config file:

<globalization fileEncoding="utf-8" requestEncoding="utf-8"
responseEncoding="utf-8" />

1. Do I also have to specify <meta http-equiv="Content-Type"
content="text/html; charset=utf-8"> in every aspx page?

2. Or also specify utf-8 in the page directive of every page?

In short, I am a bit worried that when I see the source of my generated
aspx pages I see no meta information regarding the encoding. Should I
also be adding this into every page or is it not necessary as long as
it's specified in web.config?
 
Hi,
I wish my aspx pages to be interpreted as UTF-8 by browsers.

Apart from setting the following in the web.config file:

<globalization fileEncoding="utf-8" requestEncoding="utf-8"
responseEncoding="utf-8" />

1. Do I also have to specify <meta http-equiv="Content-Type"
content="text/html; charset=utf-8"> in every aspx page?

It is not necessary. Setting the encoding in the configuration file adds
the specified information to the request. Using META is useful if you
don't have access to the request's header, but if you use server-side
code, it's better to use the request's header directly.
2. Or also specify utf-8 in the page directive of every page?

If you want the setting to be valid for each page in your application,
use the configuration file.

If you want to specify something different for a given page, use the
Page directive.

This is valid for every setting, not only encoding.
In short, I am a bit worried that when I see the source of my generated
aspx pages I see no meta information regarding the encoding. Should I
also be adding this into every page or is it not necessary as long as
it's specified in web.config?

To check that this is working, check "Auto-select" in View / Encoding in
IE. Then load your page. Then check what the browser uses in View /
Encoding. It should be UTF8 (which is not the default).

Also, you can use Fiddler to check the Request header.

HTH,
Laurent
 
Adding to Laurent's correct on-target explanation, you should grab yourself
a copy of ieHTTPHeaders, which shows you all the HTTP headers
included in the page you're displaying.

http://www.blunck.se/iehttpheaders/iehttpheaders.html

It's free...and very useful to verify whether any header is included in any page.

You turn it on, or off, after you install it,
by selecting "View", "Explorer Bar", "ieHttpHeaders" in IE.



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/
===================================
 
Thanks for that Juan. Will install it now.

Steve said:
Adding to Laurent's correct on-target explanation, you should grab yourself
a copy of ieHTTPHeaders, which shows you all the HTTP headers
included in the page you're displaying.

http://www.blunck.se/iehttpheaders/iehttpheaders.html

It's free...and very useful to verify whether any header is included in any page.

You turn it on, or off, after you install it,
by selecting "View", "Explorer Bar", "ieHttpHeaders" in IE.



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/
===================================
 
Back
Top