confused over utf-8 encoding

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?
 
L

Laurent Bugnion

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
 
J

Juan T. Llibre

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.
 
S

Steve

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.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top