page encoding FAQs

Source: Internet
Author: User

If you want to set page encoding for the entire project, you can add a Globalization attribute to the Web. config file and set its fileEncoding, requestEncoding, and responseEncoding features:
<System. web>
FileEncoding = "UTF-8"
RequestEncoding = "UTF-8"
ResponseEncoding = "UTF-8"
Culture = "en-US"
UiCulture = "de-DE"
</System. web>
If you want to set encoding for a separate Page, you can set the RequestEncoding and ResponseEncoding features of the @ Page command:
<% @ Page RequestEncoding = "UTF-8" ResponseEncoding = "UTF-8" %>

Sometimes we have set the encoding of the entire site to gb2312 in the configuration file, but a page needs to use UTF-8. In this case, we can add a location node in the configuration file section:
Program code
<Location path = "Test. aspx">
<System. web>
<Globalization fileEncoding = "UTF-8" requestEncoding = "UTF-8" responseEncoding = "UTF-8" culture = "en"/>
</System. web>
If you want to set a page to gb2312 separately, it is:
Program code <location path = "Test. aspx">
<System. web>
<Globalization fileEncoding = "gb2312" requestEncoding = "gb2312" responseEncoding = "gb2312" culture = "zh-CN"/>
</System. web>

The following is a reference for some netizens to solve the problem:

When I used ASP. NET to write the online payment interface program, I encountered a strange problem. All the Chinese characters submitted through the form were garbled and the English language was normal. For testing with asp, you can submit Chinese characters normally. The asp page contains the following HTML code:

<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">

However, adding this code to the ASP. NET page still cannot solve the problem. After analysis, the problem should be caused by encoding. The program of the other party can only process the Chinese data submitted by the GB2312 encoding page. Is ASP. NET not displayed in GB2312 encoding after the above Code is added? Open the page, check the browser code, the original is UTF-8, the reason to find, how to solve it? It seems that ASP. NET ignores the above Code and sends the encoding information to the browser. Then I will try setting Response. ContentEncoding and add the following code in Page_Load:

Response. ContentEncoding = System. Text. Encoding. GetEncoding ("GB2312 ");

OK! Solve the problem!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.