简体   繁体   English

如何设置IIS网站的默认编码?

[英]How to set IIS website's default encoding?

My website is a combination of classic ASP and ASP.NET我的网站是经典的 ASP 和 ASP.NET 的结合

My pages' default encoding is currently ISO-8859-1 .我的页面的默认编码目前是ISO-8859-1

Even if there's no <meta> tag, the response page will be encoded ISO-8859-1 .即使没有<meta>标签,响应页面也会被编码为ISO-8859-1

How to change it to UTF-8 ?如何将其更改为UTF-8

The content encoding is set in the Machine.config file when the .NET Framework is installed.安装 .NET Framework 时,内容编码在Machine.config文件中设置。 You can edit this file which will affect the response encoding of all ASP.NET sites, or you can override it on a per-site basis using the <globalization> element in each site's Web.config file.您可以编辑此文件,这将影响所有 ASP.NET 站点的响应编码,或者您可以使用每个站点的Web.config文件中的<globalization>元素在每个站点的基础上覆盖它。

MSDN Link MSDN链接

You could try adding the header to the HTTP Response Headers list for that site.您可以尝试将标头添加到该站点的 HTTP 响应标头列表中。 If none is specified, it will be delivered in whatever the user agent requests, which is likely why you're seeing the ISO-8859-1如果没有指定,它将在用户代理请求的任何内容中交付,这可能是您看到 ISO-8859-1 的原因

"Properties" => "HTTP Headers" => "File Types..." => "New Type...". “属性”=>“HTTP 标头”=>“文件类型...”=>“新类型...”。 Put in the extension you want to map, separately for each extension;放入你要映射的扩展名,分别为每个扩展名; IIS users will probably want to map .htm, .html,... Then, for Content type, add "text/html;charset=utf-8" (without the quotes; substitute your desired charset for utf-8; IIS 用户可能想要映射 .htm、.html、... 然后,对于内容类型,添加“text/html;charset=utf-8”(不带引号;将所需的字符集替换为 utf-8;

FROM: http://www.w3.org/International/O-HTTP-charset.en.php来自: http : //www.w3.org/International/O-HTTP-charset.en.php

On Windows Server 2019 you can set "Use Unicode UTF-8 for worldwide language support".在 Windows Server 2019 上,您可以设置“使用 Unicode UTF-8 进行全球语言支持”。 At the moment of writing it's still in beta and I can't find any official documentation.在撰写本文时,它仍处于测试阶段,我找不到任何官方文档。 Enabling will most likely do the job.启用很可能会完成这项工作。

Control Panel -> Region -> TAB: Administrative -> BUTTON: Change System Locale控制面板 -> 区域 -> TAB:管理 -> 按钮:更改系统区域设置

You will need to reboot the server after changing this setting.更改此设置后,您需要重新启动服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM