The cause of the problem
To facilitate viewing of the online problem log, a new site is created on IIS on the server, the root directory points to the log directory, and directory browsing begins;
Well, you can enter the site, see the list of directories, find a TXT file, click to see the Log, Yi, how the Chinese into the #%$@
Well, this problem has always been dealt with by clicking on the Chrome menu = "More tools =" code = "UTF8 can be solved,
I skillfully open the menu, I find, find, Find, the Code menu where to go ... What the heck.
Originally, Chrome said its automatic detection function is very cow B, the coding options to remove, removed ...
What to do. Can only start from the IIS server, search for half a day of data, find a solution, in the site root directory web.config add the following configuration:
<?xml version= "1.0" encoding= "UTF-8"?>
<configuration>
<system.webServer>
< httpprotocol>
<customHeaders>
<add name= "Content-type" value= "text/plain; Charset=utf-8"/>
</customHeaders>
Well, sure enough, TXT file is not garbled.
Wait, how does the directory list become HTML ...
The above configuration in the plain, change into text/html how to do.
I go, TXT file again into HTML to parse, so there will be XSS attack possible ah ...
Changed to be as follows, without any effect:
<add name= "Content-type" value= "Charset=utf-8"/>
Finally, he groped for a long time, found the solution, or change web.config, the content is as follows, simply to set the txt extension mimetype:
<?xml version= "1.0" encoding= "UTF-8"?>
<configuration>
<system.webServer>
< Directorybrowse enabled= "true" showflags= "Date, Time, Size, Extension, longdate"/>
<staticContent>
<remove fileextension= ". txt"/>
<mimemap fileextension= ". txt" mimetype= "text/plain;charset=utf-8"/ >
</staticContent>
</system.webServer>
</configuration>
Finally, self-review: Can I not be so smart ...