我想提交一段html代码到:http://validator.w3.org/#validate_by_input.然后获取他的验证结果
我用http watch看了下,post的格式为:
doctype Inline
fragment test html code
group 0
prefill 0
prefill_doctype html401
我的代码如下:
string _validateSite = "http://validator.w3.org/check";
String _postStr = "doctype=Inline&fragment" + this.txb.Text+"&group=0&prefill=0&prefill_doctype=html401";
string _strResult = "";
try
{
byte[] _byte = System.Text.Encoding.UTF8.GetBytes(_postData);
HttpWebRequest _httpRequest = (HttpWebRequest)WebRequest.Create(_url);
_httpRequest.ContentType = "application/x-www-form-urlencoded";
_httpRequest.ContentLength = _byte.Length;
_httpRequest.Method = "POST";
Stream _postStream = _httpRequest.GetRequestStream();
_postStream.Write(_byte, 0, _byte.Length);
_postStream.Close();
HttpWebResponse _response = (HttpWebResponse)_httpRequest.GetResponse();
Stream _streamReceive = _response.GetResponseStream();
Encoding _encoding = Encoding.GetEncoding("UTF-8");
StreamReader _streamReader = new StreamReader(_streamReceive, _encoding);
_strResult = _streamReader.ReadToEnd();
}
catch (Exception err)
{
_strResult = err.Message;
}
return _strResult;
发现监控我程序的post数据格式为:
__EVENTVALIDATION /wEWAwLeq5XpBgKMx9HrBwKM54rGBjWkVy5dxqfO4J8maqnNmQjYcmkH
__VIEWSTATE /wEPDwUKMTkwNjc4NTIwMWRkR7CqFW2X0Z/oejoy2A+0tQIg/8U=
Button1 Button
txb test html code
然后验证结果总是跟直接在他的site上验证的不一样,要么显示文档不可识别,要么就是只验证我提交了部分html代码
请问这是怎么回事呢?谢谢
你可以用一定的工具想:httpwatch截取post的数据,包括cookie等内容。一般都屡试不爽