简体   繁体   中英

Encoding Of An Asp.net Web Page - Possible Ways - Deifference - web.config (Globalization) vs. Meta Tag vs. etc

What are the possible ways to encode an Asp.net Web Page?

What is the difference between web.config (Globalization) in the link below:

How to: Select an Encoding for ASP.NET Web Page Globalization

And a meta tag like below:

http://www.w3schools.com/tags/att_meta_http_equiv.asp

(also we can select encoding on every page in PAGE DIRECTIVE, so what is the difference between that and the <meta> http-equiv attribute?)

The encoding you set in web.config allows you to configure the encoding that pages should be sent in .

The encoding you set in a Page directive allows you to override the web.config setting for individual pages (Word of advise - don't use it).

The encoding you set in the META tags or the response headers (ASP .NET will set response headers automagically for you); is a helpful hint to the browser about which encoding the page is sent in, so that it can decode it correctly .

In other words, the encoding in web.config, headers and in meta-tags should be set to the same encoding for things to work properly. UTF-8 is a good choice - it handles most (western european, at least) international chaaracters, and it is single byte per character unless the character is above codepoint 128 (in other words, english text is the same size in UTF8 and ASCII - so no excuse for sticking with ASCII !).

Link to the obligatory article about encodings - if you haven't yet, read it. It will save you some grief in the future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM