M
M
mindgrow2021-10-13 07:38:26
IIS
mindgrow, 2021-10-13 07:38:26

How to configure the server so that the browser opens the page in the desired encoding?

I want to place a txt document on the server, which will be opened when entering the site on the main page.
In the document, the markup is through tabulation and a new line, so I placed the document in text form.
I configured the default page in IIS so that the site considers my wiki.txt as the default page.

The problem is that when the browser receives the document, it reads it in a different encoding than the document itself, so the document is rendered unreadable. The document is in UTF-8 and the browser reads it in windows-1251.

Set up web.config like this

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <system.web>
<globalization 
         requestEncoding="utf-8"
         responseEncoding="utf-8" uiCulture="ru" culture="ru-RU" enableClientBasedCulture="false"/>
   </system.web>
    <system.webServer>
        <defaultDocument>
            <files>
                <add value="wiki.txt" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>


Did not help.
Tried enableClientBasedCulture = true - didn't help either.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
rPman, 2021-10-13
@mindgrow

https://stackoverflow.com/questions/34983425/iis-8...
needs to be added to

<configuration>
   <system.webServer>
      <staticContent>
...
         <remove fileExtension=".txt" />
         <mimeMap fileExtension=".txt"  mimeType="text/plain; charset=utf-8" />
...
      </staticContent>
   </system.webServer>
</configuration>

M
Mikhail Lyalin, 2021-10-13
@mr_jok

txt format is not the most suitable for storing structured and formatted information on the site

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question