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!