首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

WinForm客户端向网页模拟POST数据中含有(符号&)如何避免

2012-01-23 
WinForm客户端向网页模拟POST数据中含有(符号&)如何处理?比如POST一篇文章,文章中含有这样的HTML字符,但是

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

热点排行