IIS 6 - Classic ASP - Set the * .asp content type of the response header to "text / html; charset = UTF-8"

How to install *.asp files (classic ASP) on a website in IIS so that the content-Type response header is set to text/html;charset=UTF-8 ? Right now the files are served as Content-Type=text/html .

An alternative approach is to add <% Response.Charset = "UTF-8" %> to each individual page, but I am wondering if there is a way to do this globally.

Thanks! -K

+6
source share
2 answers

Globally, CharSet not specified for the application.

This is actually more than just telling the client that it received UTF-8. You must also ensure that the response object is configured to code page 65001. This can at least be set globally using the AspCodePage metabase AspCodePage at the application level (or directly in the ASP function in IIS7 Manager).

However, my preference for this is to avoid a server freeze that will be configured correctly. Each page sets its own code page (either with the @CODEPAGE directive, or with the help of Response.Codepage ) and its CharSet .

I have two reasons for this approach. One of them is that ultimately CharSet / Codepage is the choice made during the creation and saving of the file. Another is that when you depolate / copy a site, the less you have to remember in order to configure it better.

+3
source

EDIT 1: Ive checked this with IE9 Developer Tools (Network Tab)

 <% response.ContentType = "text/html;charset=UTF-8" %> 

Results in the HTML header for Content-Type:

 text/html;charset=UTF-8 

While it is not installed at the MIME level on IIS7, I will update the answer when I find out why.

EDIT 2: I cannot use the global MIME approach to work on my test bench - sorry! There are clues about this on the Internet: http://forums.iis.net/p/1166956/1941076.aspx#1941076

I assume that you just need to put response.ContentType = "text/html;charset=UTF-8" in type <!-- #include file="..\includes\common.asp" --> include (or similar )

+5
source

Source: https://habr.com/ru/post/909643/


All Articles