asp.ent中把utf-8转换成gb2312格式
如果网站的web.config配置的是全站编码为utf-8 : <globalization requestEncoding="utf-8" responseEncoding="utf-8" />,这时候如何把部分页面转换成gb2312的呢?
那么我们就把要转换gb2312的文件单独放在一个文件夹中,然后在这个文件夹中在放一个web.config文件,文件的内容是:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation defaultLanguage="c#" debug="true" />
<authorization>
<allow users="*" />
</authorization>
<trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />
<customErrors mode="Off" />
<globalization requestEncoding="gb2312" responseEncoding="gb2312"/>
<pages validateRequest="false" enableEventValidation="false" enableViewStateMac="false" viewStateEncryptionMode ="Never" />
<xhtmlConformance mode="Legacy"/>
<httpRuntime maxRequestLength="2097151" executionTimeout="3600"/>
</system.web>
</configuration>
这样就可以把这个文件夹中的文件的编码都改成gb2312的了。
关于另一种说法,在页面上添加:<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 这段代码我发现在这种情况下是不管用的。

浙公网安备 33010602011771号