<span style="color:#666666;">//Page.Request.ContentEncoding = Encoding.GetEncoding("GB2312");
//Page.Response.ContentEncoding = Encoding.GetEncoding("GB2312");
//Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
//Request.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
//Response.Charset = "936"; </span>
.net utf-8编码向gb2312网站提交数据,我们首先需要转码
只需要做2件事情
第1件在web.config中的configuration节点内单独指定编码
<location path="bankAdd.aspx" >
<system.web>
<globalization fileEncoding="GB2312" requestEncoding="GB2312" responseEncoding="GB2312" culture="zh-CN"/>
</system.web>
</location>
或者如头部所示代码在页面中再指定编码,页面顶部的第一句话也加一下编码ResponseEncoding="gb2312"
这2种方法任选其一
第2件对文字进行编码
bankName = HttpUtility.UrlEncode(bankName.ToString(), Encoding.GetEncoding("gb2312"));