When the Asp.net website runs normally, perform a web test as follows:
A strange thing occurred during the web test, as shown in,
In this case, we first analyze the problem. The possibility of Garbled text is the webpage encoding problem. Unicode encoding is gradually becoming the most common solution supported by multiple languages. Unicode-Encoded chinese web pages are compatible with various platforms and browsers. UTF-8 is a storage/exchange implementation method of Unicode. Unicode codes of different numeric ranges are encoded in a variable length mode. All ASCII characters occupy 1 byte, and those greater than 0x7f occupy 2 to 4 bytes. We can see that all ASCII files are directly compatible with UTF-8. In addition, for files with a large portion of the ASCII characters such as the Web source code, it is typically more space-saving than other Unicode storage/Interchange Formats (such as UTF-16, utf-32, and so on. Therefore, UTF-8 is widely used in website design.
All pages on my website are encoded in gb2312 format, but ASP. the default encoding in net is UTF-8, so we can find this problem from the wrong page, although we changed the request property from the original UTF-8 to gb2312 in the test case, but the test still found that the response returned packet was returned in the form of a UTF-8, in this way, the entire webpage can be garbled.
Solution:
The first solution: the use of ASP. NET encoding default way of UTF-8, the whole site of all Web Page code modified to the form of UTF-8, do not use gb2312.
Solution 2: If you still want to use gb2312 encoding for the webpage page, you can add the following code to the website configuration file web. config.
<Configuration>
<System. Web>
<Globalization fileEncoding = "gb2312" requestEncoding = "gb2312" responseEncoding = "gb2312" responseHeaderEncoding = "gb2312"/>
</System. web>
<Configuration>
WEB Testing after modification