Research on setting multiple encoding methods in the configuration file of asp.net, asp.net configuration file

Source: Internet
Author: User

Research on setting multiple encoding methods in the configuration file of asp.net, asp.net configuration file

When we are working on the asp.net program, there must be a web. config file in the root directory,

Some developers may know that it is the place where the global information of the configuration program is located,

Of course, you can also do more here. Next we will study how to set multiple encoding methods in a configuration file,

When a project is generated for the first time, a web. config file is generated for the project,

The web. config file is an xml file. The generated web. config file contains the following node: <system. web>

You can set <globalization requestEncoding = "gb2312" responseEncoding = "gb2312"/>

We can see that we set the gb2312 encoding. Of course, you are also set to "UTF-8" and other formats,

However, there is a conflict. What should we do when we want to configure the multi-medium encoding mode under a website?

Don't worry. Microsoft provides us with a solution:

There is a <configuration> node at the top of the web. config file,

You can control the encoding method of the specified file by setting the subnode of the current contact:

The format is as follows:

<Location path = "gindex. aspx">
<System. web>
<Globalization fileEncoding = "UTF-8" requestEncoding = "UTF-8" responseEncoding = "UTF-8" culture = "zh-CN"/>
</System. web>
</Location>

With the above configuration, we can implement multi-medium encoding in a solution, where in <location path = "gindex. aspx">

The path attribute refers to the file to be specially encoded!

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.