如果網站的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" /> 這段代碼我發現在這種情況下是不管用的。