使用GET方法向短信HTTP接口发送信息,但是中文却显示乱码? 但是我直接把这条链接放在IE地址栏里却是正常的? 我也已经修改了WEBCONFIG中的字符集为GB2312可是还不行?
......
string strSMSUrl = "http:....msg=中文";
HttpWebRequest hwrqSMS = (HttpWebRequest)WebRequest.Create(strSMSUrl);
HttpWebResponse hwrpSMS = (HttpWebResponse)hwrqSMS.GetResponse();
......
抓包显示字符确实不一样,请问应该怎么修改? 多谢
......
string strSMSUrl = "http:....msg=中文";
HttpWebRequest hwrqSMS = (HttpWebRequest)WebRequest.Create(strSMSUrl);
HttpWebResponse hwrpSMS = (HttpWebResponse)hwrqSMS.GetResponse();
......
抓包显示字符确实不一样,请问应该怎么修改? 多谢
<globalization
requestEncoding="gb2312"
responseEncoding="gb2312"
/>
<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
/>System.Web.HttpUtility.UrlEncode(this.txtgrpid.Text.Trim())
System.Web.HttpUtility.HtmlDecode(Request.QueryString["grpid"])
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-US"/>
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();
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)
to truelove12(醉倒在巷口): HTTP接口是公司另外一个部门提供的,他们那里到运营商那里有数据链路,具体的我也不是很懂:(
结贴~