有时候我们也许需要这样,在UFT-8的编码下提交GB2312数据给其它站处理。
那么有个最简单的办法如下:
在web.config中configuration标签下加入如下代码
(文件名需要在根目录哦。)
<location path="sendContent_manage.aspx">
<system.web>
<globalization fileEncoding="GB2312" requestEncoding="GB2312" responseEncoding="GB2312" culture="zh-CN"/>
</system.web>
</location>
在主页面中加入如下框架
<iframe src="/sendContent.html" id=pluginFra name=pluginFra frameborder=0 marginheight=0 marginwidth=0 width=0 height=0 style=display:none;></iframe>
<script>document.getElementById("pluginFra").src = "/sendContent_manage.aspx?to_userid=";</script>
sendContent.html内容如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>短信发送</title> </head> <body>no </body> </html>
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" %> <% /** * *********************************************** * Author:prospertu * CreateDate:2015/11/14 11:18 * Note:在后台短信发送 * ************************************************ */ %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>send message</title> </head> <body> <% 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"; string mobileNum = "手机号"; to_content = "短信内容"; to_content = Server.UrlEncode(to_content); string url_sendInfo = "http://发短信?mobile=" + mobileNum + "&content=" + to_content;//tl=1 Response.Write("<script>location.href='" + url_sendInfo + "';</script>"); %> </body> </html>