{"id":733,"date":"2007-10-20T21:31:17","date_gmt":"2007-10-20T13:31:17","guid":{"rendered":"http:\/\/blog.myhz.com\/blog\/2010\/05\/06\/%e5%af%b9%e4%ba%8easp%e7%bc%96%e7%a0%81%e9%97%ae%e9%a2%98%e7%9a%84%e6%b7%b1%e5%85%a5%e7%a0%94%e7%a9%b6%e4%b8%8e%e6%9c%80%e7%bb%88%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88%e8%bd%ac%e5%b8%96\/"},"modified":"2010-05-07T11:19:46","modified_gmt":"2010-05-07T03:19:46","slug":"%e5%af%b9%e4%ba%8easp%e7%bc%96%e7%a0%81%e9%97%ae%e9%a2%98%e7%9a%84%e6%b7%b1%e5%85%a5%e7%a0%94%e7%a9%b6%e4%b8%8e%e6%9c%80%e7%bb%88%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88%e8%bd%ac%e5%b8%96","status":"publish","type":"post","link":"https:\/\/ivan.xin\/?p=733","title":{"rendered":"\u5bf9\u4e8eASP\u7f16\u7801\u95ee\u9898\u7684\u6df1\u5165\u7814\u7a76\u4e0e\u6700\u7ec8\u89e3\u51b3\u65b9\u6848[\u8f6c\u5e16]"},"content":{"rendered":"<p>Ivan \u53d1\u8868\u4e8e 2007-10-20 21:31:00<\/p>\n<p>\u54ea\u7684\u8d44\u6599\u90fd\u4e0d\u5982\u5b98\u65b9\u8d44\u6599\u6743\u5a01\u3002\u4eca\u5929\u603b\u7b97\u4eceMSDN\u4e2d\u62e9\u51fa\u4e86ASP\u7f16\u7801\u95ee\u9898\u7684\u89e3\u51b3\u65b9\u6848\u3002<br \/>\n\u4e0b\u9762\u662fMSDN\u4e2d\u7684\u4e00\u6bb5\u8bdd\u3002<br \/>\nSetting @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.<\/p>\n<p>\u8fd9\u53e5\u8bdd\u89e3\u91ca\u6e05\u695a\u4e86@CODEPAGE\uff0cResponse.CodePage\uff0cSession.CodePage \u5206\u522b\u7684\u4f5c\u7528\u662f\u4ec0\u4e48\u3002<br \/>\n@CODEPAGE\u4f5c\u7528\u4e8e\u6240\u6709\u9759\u6001\u7684\u5b57\u7b26\u4e32\uff0c\u6bd4\u5982\u67d0\u6587\u4ef6\u4e2d\u7684 const blogname=\"\u6211\u7684\u5bb6\"<br \/>\nResponse.CodePage,Session.CodePage\u4f5c\u7528\u4e8e\u6240\u6709\u52a8\u6001\u8f93\u51fa\u7684\u5b57\u7b26\u4e32\uff0c\u6bd4\u5982&lt;%=blogname%&gt;<br \/>\n\u8fd9\u53e5\u8bdd\u5f88\u5173\u952e\u7684\u662f\u8bf4\u660e\u4e86Response.CodePage\u7684\u4f5c\u7528\u8303\u56f4\u662fa single response\uff0c\u800cSXNA\u4e2d\u58f0\u660e\u7684Session.CodePage\u7684\u4f5c\u7528\u8303\u56f4\u662fall responses in a session\u3002<br \/>\n\u518d\u770b\u53e6\u5916\u4e00\u53e5\u8bdd\u3002<br \/>\nIf 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 code page.<\/p>\n<p>\u8fd9\u53e5\u8bdd\u6211\u4e4d\u4e00\u770b\uff0c\u628a\u610f\u601d\u7406\u89e3\u6210\u4e86\u8fd9\u6837\uff1a\u5728sessions are enabled\u7684\u65f6\u5019\uff0c\u5982\u679cResponse.CodePage\u6ca1\u6709\u58f0\u660e\uff0c\u5219Response.CodePage\u4f1a\u88abSession.CodePage\u8d4b\u503c\u3002\u5982\u679csessions are not enabled\u7684\u65f6\u5019, \u5982\u679c@CodePage\u5df2\u58f0\u660e\uff0c\u5219Response.CodePage\u4f1a\u88ab@CodePage\u8d4b\u503c\uff0c\u7b49\u7b49.............<br \/>\n\u8fd9\u53e5\u8bdd\u89e3\u91ca\u4e86\u4e3a\u4ec0\u4e48\u4eceSXNA\u4e2d\u51fa\u6765\u4ee5\u540e\u8fdb\u5165\u4e00\u4e9b\u522b\u7684\u9875\u9762\u6bd4\u5982oblog,z-blog\u7b49\u7b49\u5bb9\u6613\u51fa\u73b0\u4e71\u7801\uff0c\u56e0\u4e3a\u5176\u4ed6\u7a0b\u5e8f\u6ca1\u6709\u58f0\u660e Response.CodePage\u800c\u6070\u5de7SXNA\u58f0\u660e\u4e86Session.CodePage\uff0c\u56e0\u6b64\u4e00\u8fdb\u5165SXNA\uff0cSession.CodePage\u7acb\u5373\u88ab\u8d4b\u503c\uff08\u7248\u672c\u4e0d\u540c\uff0c\u6709\u7684\u7248\u672c\u8d4b\u4e86936\u6709\u7684\u7248\u672c\u8d4b\u4e8665001\uff09\uff0c\u800c\u540e\u8fdb\u5165\u5176\u4ed6\u7a0b\u5e8f\u7684\u65f6\u5019Response.CodePage\u9a6c\u4e0a\u88abSession.CodePage\u8d4b\u503c\uff0c\u5982\u679c\u8fd9\u65f6Response.CodePage\u4e0e\u9875\u9762\u672c\u8eab\u7f16\u7801\u4e0d\u4e00\u6837\u7684\u8bdd\uff0c\u9875\u9762\u5c31\u4f1a\u51fa\u73b0\u4e71\u7801\u3002\u6240\u4ee5\u8fdb\u5165z-blog\u51fa\u73b0\u4e71\u7801\u7684\u65f6\u5019\u6211\u67e5\u4e86\u5f53\u65f6\u7684Session.CodePage\u548cResponse.CodePage\u90fd\u662f936\uff0c\u800c\u8fdb\u5165oblog\u51fa\u73b0\u4e71\u7801\u7684\u65f6\u5019Session.CodePage\u548cResponse.CodePage\u90fd\u662f65001.\u5c31\u662f\u8bf4\u8981\u60f3\u4fdd\u8bc1\u53f6\u9762\u4e0d\u51fa\u73b0\u4e71\u7801\uff0c\u5e94\u8be5\u58f0\u660eResponse.CodePage\uff0c\u5426\u5219\u4ed6\u5c31\u4f1a\u6309\u7167Session.CodePage\u6765\u89e3\u91ca\u7f51\u9875\uff08\u800c\u4e0d\u662f\u6309\u7167@codepage\u89e3\u91ca\u7f51\u9875\uff09.<br \/>\n\u5982\u679c\u4ec5\u4ec5\u6309\u7167\u4e0a\u9762\u7684\u89e3\u91ca\u7684\u8bdd\uff0c\u6211\u5b9e\u9645\u4e0a\u662f\u5f88\u7cca\u6d82\u7684\uff0c\u56e0\u4e3a\u6211\u4eec\u90fd\u662f\u7528\u7684\u4e2d\u6587\u64cd\u7cfb\u7edf\uff0c\u5f53\u6bcf\u4e00\u6b21\u8fdb\u5165\u6d4f\u89c8\u5668\u7684\u65f6\u5019\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u8f93\u51fa Session.CodePage\uff0c\u80fd\u770b\u5230\u4ed6\u90fd\u662f936\uff01\u4e3a\u4ec0\u4e48\u8fdb\u5165Z-blog\u7684\u65f6\u5019\u4ed6\u4e0d\u628a\u9ed8\u8ba4\u7684Session.CodePage\u7684936\u8d4b\u7ed9 Response.CodePage\u5462\uff1f\u53cd\u800c\u628a@CodePage\u7ed9\u4e86Response.CodePage\uff1f\u4ec0\u4e48\u60c5\u51b5\u4e0bSession.CodePage \u624d\u8d4b\u503c\u7ed9Response.CodePage\u5462\uff1f\u539f\u6587\u7684sessions are enabled\u5e94\u8be5\u5982\u4f55\u7406\u89e3\u5462\uff1f<br \/>\n\u4e5f\u8bb8\u4e0a\u9762\u7684\u8bdd\u5e94\u8be5\u8fd9\u6837\u7406\u89e3\uff1a<br \/>\n\u5728Session.CodePage\u88ab\u4efb\u4f55\u7a0b\u5e8f\u58f0\u660e\u7684\u65f6\u5019\uff0c\u5982\u679cResponse.CodePage\u6ca1\u6709\u58f0\u660e\uff0c\u5219Response.CodePage\u4f1a\u88abSession.CodePage\u8d4b\u503c\u3002\u5982\u679cSession.CodePage\u6ca1\u6709\u88ab\u4efb\u4f55\u7a0b\u5e8f\u58f0\u660e\u7684\u65f6\u5019, \u5982\u679c@CodePage\u5df2\u58f0\u660e\uff0c\u5219Response.CodePage\u4f1a\u88ab@CodePage\u8d4b\u503c\uff0c....\uff0c\u6700\u540e\u7684\u9875\u9762\u52a8\u6001\u5185\u5bb9\u90e8\u5206\u6309\u7167Response.CodePage\u7684\u503c\u89e3\u91ca\u3002<\/p>\n<p>\u56e0\u4e3aZblog\u548cOblog\u90fd\u58f0\u660e\u4e86@CodePage\uff0c\u6240\u4ee5\uff0c\u7528\u6237\u521a\u521a\u542f\u52a8\u5b8c\u673a\u5668\u7136\u540e\u8fdb\u5165\u6d4f\u89c8\u5668\u6d4f\u89c8Zblog\u548cOblog\u7684\u65f6\u5019Response.CodePage\u4f1a\u88ab@CodePage\u8d4b\u503c\uff0c\u4e8e\u662f\u53f6\u9762\u663e\u793a\u6b63\u5e38\u3002<br \/>\n\u8fd9\u53e5\u8bdd\u8fdb\u4e00\u6b65\u89e3\u91ca\u4e86\u4ea7\u751f\u4e71\u7801\u7684\u539f\u56e0<br \/>\nIf you set Response.CodePage or Session.CodePage explicitly, do so before sending non-literal strings to the client. If you use literal and non-literal strings in the same page, make sure the code page of @CODEPAGE matches the code page of Response.CodePage, or the literal strings are encoded differently from the non-literal strings and display incorrectly.<\/p>\n<p>\u5176\u4e2d\u6bd4\u8f83\u6709\u7528\u7684\u4e00\u53e5\u8bdd\u662f\u8bf4\u5982\u679cResponse.CodePage\u548c@CODEPAGE\u4e0d\u4e00\u6837\u7684\u8bdd\u4f1a\u4ea7\u751f\u4e71\u7801\u3002\u4e5f\u5c31\u662f\u8bf4\u5f53Z-blog\u7684@CODEPAGE=65001\u800cZ-blog\u7684Response.CodePage\u88abSession.CodePage\u8d4b\u4e3a936\u7684\u65f6\u5019\u5c31\u4f1a\u51fa\u73b0\u4e71\u7801\uff0coblog\u53cd\u4e4b\u4ea6\u7136\u3002<br \/>\n\u4e0d\u77e5\u9053\u4e0a\u9762\u8bf4\u4e86\u8fd9\u4e48\u591a\u89e3\u91ca\u6e05\u695a\u6ca1\u6709-_-||<br \/>\n\u4e0b\u9762\u89e3\u91ca\u4e00\u4e0b\u4e3a\u4ec0\u4e48SXNA\u6709\u65f6\u4f1a\u628aSession.CodePage\u8d4b\u4e3a936\uff0c\u6211\u6709\u4e00\u4e2a\u7248\u672c\u662f\u8fd9\u6837\u5199\u7684\uff1a<br \/>\n&lt;% OriginalCodePage=Session.CodePage %&gt;<br \/>\n.......<br \/>\n&lt;% Session.CodePage=OriginalCodePage %&gt;<\/p>\n<p>\u5f53\u7528\u6237\u8fdb\u5165\u6d4f\u89c8\u5668\u7684\u65f6\u5019Session.CodePage\u9ed8\u8ba4\u4e3a936\uff0c\u8fd9\u4e2a\u65f6\u5019\u7684\u9ed8\u8ba4936\u4e0d\u662f\u7a0b\u5e8f\u58f0\u660e\u7684\uff0c\u56e0\u6b64\u4e0d\u4f1a\u8d4b\u7ed9Response.CodePage\uff0c\u5f53\u8fdb\u5165SXNA\u7684\u65f6\u5019\uff0cSession.CodePage\u88ab\u4e0a\u9762\u90a3\u6bb5\u4ee3\u7801\u4e00\u6298\u817e\u5c31\u53d8\u6210\u4e86\u7a0b\u5e8f\u58f0\u660e\u7684Session.CodePage=936,\u56e0\u6b64\u518d\u8fdb\u5165Zblog\u7684\u65f6\u5019\u5c31\u628a936\u7ed9\u4e86Response.CodePage\u3002<br \/>\n\u81f3\u6b64\uff0c\u5168\u90e8\u539f\u56e0\u5df2\u7ecf\u5206\u6790\u6e05\u695a\u4e86\u3002<br \/>\n\u56e0\u6b64\u8bf4\uff0c\u4fdd\u8bc1asp\u53f6\u9762\u4e00\u5b9a\u4e0d\u4f1a\u51fa\u73b0\u4e71\u7801\u7684\u4ee3\u7801\u5e94\u8be5\u662f\u8fd9\u6837\u7684\uff1a\uff08\u5047\u5b9a\u662fUTF-8\u7684\u53f6\u5b50\uff09<br \/>\n&lt;%@ CODEPAGE=65001 %&gt;<br \/>\n&lt;% Response.CodePage=65001%&gt;<br \/>\n&lt;% Response.Charset=\"UTF-8\" %&gt;<\/p>\n<p>\u8fdb\u4e00\u6b65\u8bf4\u660e\u4e3a\u4ec0\u4e48\u8981\u52a0Response.Charset\uff0c\u56e0\u4e3aMSDN\u8bf4\u5e94\u8be5\u52a0...\u5475\u5475<br \/>\nIf the code page is set in a page, then Response.Charset should also be set.<\/p>\n<p>\u53e6\u5916\uff0c\u6587\u4ef6\u7684\u7f16\u7801\u683c\u5f0f\u5e94\u8be5\u4e0e@CODEPAGE\u4e00\u6837:<br \/>\nThe file format of a Web page must be the same as the @CODEPAGE used in the page.<\/p>\n<p>\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48zblog,pjblog\u7b49\u4e00\u4e9b\u7a0b\u5e8f\u8981\u5427\u6587\u4ef6\u5b58\u6210UTF8\u7f16\u7801\u683c\u5f0f\u7684\u539f\u56e0.<br \/>\n\u7efc\u4e0a\uff0c\u5982\u679c\u6240\u6709\u7684\u7a0b\u5e8f\u90fd\u58f0\u660e\u4e86Response.CodePage\u5c31\u4e0d\u4f1a\u88abSession.CodePage\u5e72\u6270\u800c\u51fa\u73b0\u4e71\u7801\u4e86\u3002\u6240\u4ee5Session.CodePage\u8fd8\u662f\u4e0d\u80fd\u8f7b\u6613\u7528\u7684\uff01<\/p>\n<p>\u53c2\u8003\u6587\u7ae0\uff1a<br \/>\n<a href=\"http:\/\/msdn.microsoft.com\/library\/default.asp?url=\/library\/en-us\/iissdk\/html\/268f1db1-9a36-4591-956b-d7269aeadcb0.asp\" target=\"_blank\">http:\/\/msdn.microsoft.com\/library\/default.asp?url=\/library\/en-us\/iissdk\/html\/268f1db1-9a36-4591-956b-d7269aeadcb0.asp<\/a><br \/>\n<a href=\"http:\/\/msdn.microsoft.com\/library\/default.asp?url=\/library\/en-us\/iissdk\/html\/582e6f47-52eb-413e-8b5d-c99145cb61d8.asp\" target=\"_blank\">http:\/\/msdn.microsoft.com\/library\/default.asp?url=\/library\/en-us\/iissdk\/html\/582e6f47-52eb-413e-8b5d-c99145cb61d8.asp<\/a><\/p>\n<p>\u8f6c\u81ea\uff1ahttp:\/\/blog.csdn.net\/chinaPhoneLab\/archive\/2007\/09\/20\/1792710.aspx<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ivan \u53d1\u8868\u4e8e 2007-10-20 21:31:00 \u54ea\u7684\u8d44\u6599\u90fd\u4e0d\u5982\u5b98\u65b9\u8d44\u6599\u6743\u5a01\u3002\u4eca\u5929\u603b\u7b97\u4eceMSDN\u4e2d\u62e9\u51fa...<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-733","post","type-post","status-publish","format-standard","hentry","category-9"],"_links":{"self":[{"href":"https:\/\/ivan.xin\/index.php?rest_route=\/wp\/v2\/posts\/733","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ivan.xin\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ivan.xin\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ivan.xin\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/ivan.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=733"}],"version-history":[{"count":0,"href":"https:\/\/ivan.xin\/index.php?rest_route=\/wp\/v2\/posts\/733\/revisions"}],"wp:attachment":[{"href":"https:\/\/ivan.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=733"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ivan.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=733"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ivan.xin\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=733"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}