使用GET方法向短信HTTP接口发送信息,但是中文却显示乱码? 但是我直接把这条链接放在IE地址栏里却是正常的? 我也已经修改了WEBCONFIG中的字符集为GB2312可是还不行?
......
string strSMSUrl = "http:....msg=中文";
HttpWebRequest hwrqSMS = (HttpWebRequest)WebRequest.Create(strSMSUrl); 
HttpWebResponse hwrpSMS = (HttpWebResponse)hwrqSMS.GetResponse();
......
抓包显示字符确实不一样,请问应该怎么修改? 多谢

解决方案 »

  1.   

    那在你的文件中有没有设置encoding='GB2312'?
      

  2.   

    设置web.config中:
    <globalization
    requestEncoding="gb2312"
        responseEncoding="gb2312"
    />
      

  3.   

    设置web.config中:
    <globalization
    requestEncoding="utf-8"
        responseEncoding="utf-8"
    />System.Web.HttpUtility.UrlEncode(this.txtgrpid.Text.Trim()) 
    System.Web.HttpUtility.HtmlDecode(Request.QueryString["grpid"])
      

  4.   

    HttpWebRequest hwrqSMS = (HttpWebRequest)WebRequest.Create(Server.UrlEncode(strSMSUrl));
      

  5.   

    在web.config添加
       <globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-US"/>
      

  6.   

    向楼主请教一下:HTTP接口 是指移动的短信接口还是自己利用GSM MODER 来做的短信收发程序。如果不是用GSM MODER来做的,请问可不可以这样做?如何实现,非常感兴趣。多谢。
      

  7.   

    //不知道楼主 strSMSUrl 这里定位到的页面编码是哪种?string strSMSUrl = "http:....msg=中文";
    HttpWebRequest hwrqSMS = (HttpWebRequest)WebRequest.Create(strSMSUrl); 
    HttpWebResponse hwrpSMS = (HttpWebResponse)hwrqSMS.GetResponse();//帮你补充一下, 读取流并设置流的编码才能顺利读取里面的字符信息
    StreamReader sr = new StreamReader(hwrpSMS.GetResponseStream(), System.Text.Encoding.GetEncoding("GB2312"));
    string sResutContents = sr.ReadToEnd();
      

  8.   

    你可以参考一下这段代码:
    Dim req As HttpWebRequest
            Dim rep As HttpWebResponse
            Dim mr As StreamReader
            Dim str As String
            Dim i As Integer
            req = CType(WebRequest.Create("http://www.liall.com"), HttpWebRequest)
            rep = CType(req.GetResponse, HttpWebResponse)
            mr = New StreamReader(rep.GetResponseStream(), Encoding.GetEncoding("gb2312"))
            str = mr.ReadToEnd
            Response.Write(str)
      

  9.   

    多谢名位,已经好了,其实昨天后来就好了,我光注意抓包了,没注意事实上手机接收已经不乱码了,呵呵,因为使用IE地址栏发送和使用HTTP发送gb2312时的字符表示方式还是有些不同的,我没注意到这一点,:)
    to truelove12(醉倒在巷口): HTTP接口是公司另外一个部门提供的,他们那里到运营商那里有数据链路,具体的我也不是很懂:(
    结贴~