How do I can set *.asp
files (Classic ASP) in a Web Site under IIS to have Response Header's Content-Type set to text/html;charset=UTF-8
? Right now, the files are served as Content-Type=text/html
.
An alternate approach is to add <% Response.Charset = "UTF-8" %>
to every single page, but I wonder if there's a way to do it globally.
Thanks! -K
EDIT 1: Ive tested this with IE9's developer tools (network tab),
<%
response.ContentType = "text/html;charset=UTF-8"
%>
Results in a HTML header for Content-Type of:
text/html;charset=UTF-8
Whereas, setting it at the MIME level on IIS7 does not - i'll update my answer when i figure out why.
EDIT 2: I cant get the global MIME approach to work on my test rig - sorry! There are hints of this online: http://forums.iis.net/p/1166956/1941076.aspx#1941076
I'm guessing you'll just have to pop the response.ContentType = "text/html;charset=UTF-8"
in an <!-- #include file="..\includes\common.asp" -->
type include (or similar).
There is no means to globally specify the CharSet
for an application.
There is actually more to it than just telling the client its getting UTF-8. You also need to ensure the response object is configured to the 65001 codepage. This at least can be set globally using the AspCodePage
metabase value at the application level (or directly in the ASP feature in IIS7 manager).
However my preference with this sort of thing is to avoid depending on the server to be configured correctly. Each page sets its codepage (either with the @CODEPAGE
directive or with Response.Codepage
) and its CharSet
.
I have two reasons for this approach. One is that ultimately the CharSet/Codepage is choice made at the time of creating and saving the file. The other is that when depolying/copying the site the less you have to remember to configure the better.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With