如何向ASP.NET页面发回回请求?我抓住了Fiddler的数据并试图用HttpWebRequest类发出相同的请求,但是我收到错误编码的简短回答。 (尝试了各种编码,没有结果) 这是代码的一部分:
var req = (HttpWebRequest)WebRequest.Create("http://mySite.aspx?test=test");
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded; charset=utf-8";
req.Accept="*/*";
req.Headers.Add("Accept-Language", "en-us");
req.Referer="http://mysiterefer.com";
req.Headers.Add("x-microsoftajax", "Delta=true");
req.Headers.Add("Cache-Control", "no-cache");
req.Headers.Add("Accept-Encoding", "gzip, deflate");
req.UserAgent="Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3; AskTbFXTV5/5.15.1.22229)";
req.Headers.Add("Pragma", "no-cache");
req.Headers.Add("Cookie", "ASP.NET_SessionId=blablablaxur445; vehicle=1=2011@#VAZ@#2101@#; s_cc=true; s_p_s_prop8=typed-bookmarked; ev_36_getval=20120501%2000; s_sq=%5B%5BB%5D%5D");
string postData = "__EVENTTARGET=lalalala&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=veryLongBase64string&__ASYNCPOST=true&";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
req.ContentLength = byteArray.Length;
Stream dataStream = req.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
using (var response = (HttpWebResponse)req.GetResponse())
{
StreamReader objReader = new StreamReader(response.GetResponseStream());
string str = objReader.ReadToEnd();
...
}
那么,谁可以提供回发请求的示例?