.net解决乱码的旁门走道

11 篇文章 0 订阅
2 篇文章 0 订阅

有时候我们也许需要这样,在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> 

sendContent_manage.aspx内容如下:

<%@ 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>




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值