2017-07-19 517 views
0

我有这个如何在IIS web.config文件上将编码设置为utf-8?

<?xml version="1.0" encoding="UTF-8"?> 

<configuration> 

    <appSettings> 
     <add key="ContentServer" value="true" /> 
    </appSettings> 
    <connectionStrings /> 

    <system.web> 
     <trace enabled="false" requestLimit="25" pageOutput="false" traceMode="SortByTime" localOnly="false" /> 
     <customErrors mode="Off" /> 
     <compilation debug="false" /> 
     <authentication mode="Windows" /> 
    </system.web> 
</configuration> 

如何将编码设置为UTF-8发送到客户端文件。其实可以有其他类型的文件发送到客户端,如js,css,图像。但我有aspx页面,我想要设置text/html; charset=utf-8"内容类型。我如何将此添加到此web.config代码?

感谢

回答

0

您需要设置globalization elementresponseEncoding属性。

<globalization 
    responseEncoding="utf-8" 
/> 

在背景:

<configuration> 
    <system.web> 
     <globalization 
      requestEncoding="utf-8" 
      responseEncoding="utf-8" 
     /> 
    </system.web> 
</configuration> 
+0

我在哪里插入到web.config中,如果我编辑web.config,我需要重新启动IIS服务器? – omega

+0

请点击链接。该页面有一个示例,显示上下文中的元素。当您编辑web.config时,IIS将自动回收应用程序池;你不需要手动执行'iisreset'。 –