Solution to garbled Chinese display in ASP. NET

Source: Internet
Author: User
How to solve Chinese garbled characters in ASP. NET
Solution to garbled Chinese display in ASP. NET
ASP. net is flexible, thanks to the text file configuration method. in addition, the method of using page identifiers should be extended from ASP. when writing ASP + programs, I encountered a Chinese display problem. After running the program, I found that all the Chinese characters read by ASP + from the database were changed ?????, Solution:

Method 1:

Set the globalization segment in config. Web
<Configuration>
<Globalization
Requestencoding = "UTF-8"
Responseencoding = "UTF-8"
/>
</Configuration>

It can be UTF-8, gb2312, and so on.

Method 2:

Later, I subscribed to Microsoft's newsgroup and found it discussed in Microsoft's newsgroup DOTNET. Framework. aspplus. General.
To add <% @ codePage = "936" %> to the beginning of each page.
<% @ Page contenttype = "text/html; charset = gb2312" %>
Hurry up and test it. OK !!!

The example is shown below:
<% @ CodePage = "936" %>
<% @ Import namespace = "system. Data" %>
<% @ Import namespace = "system. Data. Ado" %>
<% @ Import namespace = "system. Globalization" %>
<HTML>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">

Generally, after opening the interface with dereamweaver with vs. net2003, the Chinese characters in the interface become garbled. It took several minutes to finally find a solution.

Add the code in Web. config.
. <Globalization
Requestencoding = "gb2312"
Responseencoding = "gb2312"
Fileencoding = "gb2312"
/>

Or

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

Garbled characters after release

To facilitate the release of Visual Studio 2005 as a single DLL, Microsoft released a Visual Studio 2005 plug-in, Visual Studio 2005 web deployment projects. In different Microsoft documents, this plug-in provides two, they are:

1. (The size is 905 K)
Http://download.microsoft.com/download/c/c/ B /ccb4877f-55f7-4478-8f16-e41886607a0e/webdeploymentsetup. MSI

2: (size: 919 K)
Http://download.microsoft.com/download/9/4/9/9496adc4-574e-4043-bb70-bc841e27f13c/webdeploymentsetup. MSI

When you give a link, the compiled file, if aspx contains Chinese characters, the page may be displayed as garbled characters. Therefore, please pay attention to the version. Both files are provided by Microsoft. The original article is as follows:

Http://msdn.microsoft.com/library/default.asp? Url =/library/en-US/dnaspp/html/web_deployment_projects.asp

Http://msdn2.microsoft.com/en-US/asp.net/aa337919.aspx

 

When you use vs2005 to publish a website project, the project under the bin directory is generated. DLL file names are randomly generated. Now, Ms provides plug-ins to generate custom file names (. DLL ):

Web deployment projects with Visual Studio 2005
: Http://download.microsoft.com/download/c/c/ B /ccb4877f-55f7-4478-8f16-e41886607a0e/WebDeploymentSetup.msi
Msdn description:
Http://msdn.microsoft.com/library/default.asp? Url =/library/en-US/dnaspp/html/web_deployment_projects.asp

The procedure is as follows:
1. Download and install it directly. After installation, open vs2005;
2. under [generate]-> [Publish website], an additional [add web deployment project] is displayed. You can also right-click the website project to be published. select [add web deployment project]. After the attribute dialog box is displayed. after setting the specified name and storage directory, you can see that there is one more option in the current solution. If there are many other attributes, you can set them yourself;
3. Right-click the added solution and choose [generate] to generate the corresponding file and directory.
========================================================== =====
From: http://hi.baidu.com/westsky/blog/item/5b784d81f7e49fdabd3e1edc.html

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: info-contact@alibabacloud.com 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.