关于CodePage、Response.CodePage和Session.CodePage三者的区别,MSDN说明如下:
Setting @CODEPAGE explicitly affects literal strings in a single response. Response.CodePage affects dynamic strings in a single response, and Session.CodePage affects dynamic strings in all responses in a session.
大意是CodePage影响静态文本,Response.CodePage影响动态文本,Session.CodePage的作用和Response.CodePage相同,只是它的作用范围更大,影响同一会话的所有响应。
1、CodePage和Response.CodePage的测试
<%@ CodePage=65001 %>
<%
Response.Charset="utf-8"
Response.CodePage = 936
Response.Write("这是动态文本。")
%>
这是静态文本。
<%@ CodePage=65001 %>
<%
Response.Charset="gb2312"
Response.CodePage = 936
Response.Write("这是动态文本。")
%>
这是静态文本。
<%@ CodePage=936 %>
<%
Response.Charset="gb2312"
Response.CodePage = 936
Response.Write("这是动态文本。")
%>
这是静态文本。
说明:网页文件编码为UTF-8。
2、Response.CodePage和Session.CodePage的测试
<%
Response.Charset="gb2312"
Session.CodePage = 65001
Response.CodePage = 936
Response.Write("这是动态文本。")
%>
这是静态文本。

<%
Response.Charset="gb2312"
Response.CodePage = 936
Session.CodePage = 65001
Response.Write("这是动态文本。")
%>
这是静态文本。
3、CodePage、Response.CodePage和Session.CodePage取值顺序
若未设置CodePage:
If @CODEPAGE is not explicitly set in a page, it is implicitly set by the AspCodePage metabase property or by the system ANSI code page.
若未设置Response.CodePage:
If Response.CodePage is not explicitly set in a page, it is implicitly set by Session.CodePage, if sessions are enabled. If sessions are not enabled, Response.CodePage is set by @CodePage, if @CodePage is present in the page. If there is no @CodePage in the page, Response.CodePage is set by the AspCodePage metabase property. If the AspCodePage metabase property is not set, or set to 0, Response.CodePage is set by the system ANSI codepage.
若未设置Session.CodePage:
If Session.CodePage is not explicitly set on a page, it is implicitly set by the AspCodePage metabase property. If the AspCodePage property is not set, or set to 0, Session.CodePage is set by the system ANSI code page. Session.CodePage is no longer implicitly set by @CodePage, as it was for IIS 5.0 and earlier versions. This change was made because one @CodePage could change the code page for an entire session. Now, @CodePage and Response.CodePage affect only single responses, while Session.CodePage affects all responses in a session.
4、Response.Charset的作用
还是看MSDN的说明:
If the code page is set in a page, then Response.Charset should also be set. The code page value specifies to IIS how to encode the data when building the response, and the charset value tells the browser how to decode the data when displaying the response. The CharsetName of Response.Charset must match the code page value, or mixed characters are displayed in the browser.
原神祈愿模拟器最新版
原神祈愿模拟器手机版是一款完整汉化的趣味原神抽卡模拟小游戏,
宝宝森林美食完整版
宝宝森林美食游戏最新版是一款十分有趣的休闲益智游戏,帮助宝宝
g沙盒仇恨官方英文版(gorebox)
G沙盒仇恨英文原版是一款最近非常火热的沙盒模拟类游戏,在这里
迷你世界测试服最新版2024
迷你世界测试服2021最新版,即迷你世界的先遣服版本,用户能
闪耀暖暖最新版2024
闪耀暖暖手游这是非常好玩的换装手游,游戏内容丰富有趣,游戏环