日期:2014-05-18  浏览次数:20769 次

WinForm客户端向网页模拟POST数据中含有(符号&)如何处理?
比如POST一篇文章,文章中含有       这样的HTML字符,但是POST数据中,&是作为分割两段数据的标志,nbsp;和连在后面这段数据就会被抛弃导致数据不完整,不知道应该如何处理,上次问了几次都没有得到我要的答案,希望这次能有所收获,我的POST代码如下:

string   postData   =   post;

byte[]   data   =   Encoding.GetEncoding(encode).GetBytes(postData);

HttpWebRequest   request   =   (HttpWebRequest)WebRequest.Create(url);
request.Method   =   "POST ";
request.ContentType   =   "application/x-www-form-urlencoded ";
request.ContentLength   =   data.Length;

Stream   newStream   =   request.GetRequestStream();
newStream.Write(data,   0,   data.Length);
newStream.Close();

HttpWebResponse   response   =   (HttpWebResponse)request.GetResponse();
Stream   stream   =   response.GetResponseStream();
source   =   new   StreamReader(stream,   Encoding.GetEncoding(encode)).ReadToEnd();

stream.Close();
response.Close();

------解决方案--------------------
Server.URLEncode