问题描述
做一个QQ空间的留言删除功能,删除代码如下///<summary>///删除留言///</summary>///<paramname="gtk">gtk</param>///<paramname="mig">留言ID</param>///<returns></returns>privateboolDelete(intgtk,stringmig){Uriuri=newUri("http://m.qzone.qq.com/cgi-bin/new/del_msgb?g_tk="+gtk);byte[]by=Encoding.GetEncoding("utf-8").GetBytes(string.Format("qzreferrer=http://ctc.qzs.qq.com/qzone/msgboard/msgbcanvas.html#page=1&hostUin={0}&idList={1}&uinList={2}&format=fs&iNotice=1&inCharset=utf-8&outCharset=utf-8&ref=qzone&json=1&g_tk={3}",this.textBox_QQ.Text.Trim(),mig,this.textBox2.Text.Trim(),gtk));HttpWebRequestrequest=(HttpWebRequest)WebRequest.Create(uri);request.Accept="text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";request.ContentType="application/x-www-form-urlencoded";request.Host="m.qzone.qq.com";request.ContentLength=by.Length;request.Referer="http://ctc.qzs.qq.com/qzone/msgboard/msgbcanvas.html";request.UserAgent="Mozilla/5.0(WindowsNT6.0)AppleWebKit/537.36(KHTML,likeGecko)Chrome/39.0.2171.95Safari/537.36";request.Method="post";request.CookieContainer=this.cookie;Streams=request.GetRequestStream();s.Write(by,0,by.Length);s.Close();HttpWebResponseresponse=(HttpWebResponse)request.GetResponse();this.cookie.Add(response.Cookies);Streamstream=response.GetResponseStream();StreamReaderreader=newStreamReader(stream,Encoding.Default);stringhtml=reader.ReadToEnd();reader.Close();stream.Close();request.Abort();response.Close();returntrue;}
qzreferrer=http://ctc.qzs.qq.com/qzone/msgboard/msgbcanvas.html#page=1该参数里面有#号,要怎么处理。求做过的大神支招。分不多,大家研究一下可好,谢谢啦。
解决方案
解决方案二:
要对参数值编码的,比如用utf8去encode,对方解码就可以了decode
解决方案三:
有木有大神过来给个解决方案啊
解决方案四:
引用1楼bdmh的回复:
要对参数值编码的,比如用utf8去encode,对方解码就可以了decode
这样System.Web.HttpUtility.UrlEncode(str,UTF8),还是报错,说参数错误