action的真实地址被改写了,直接post的话,返回的还是登录的页面,值传不上去,高手帮忙看下
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "username=xiaofei0804&password=19840804";
byte[] data = Encoding.GetEncoding("GB2312").GetBytes(postData);
CookieContainer ccc = new CookieContainer();
// Prepare web request
HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create("http://www.gxhouse.com/2sf/User_Login.aspx");
myRequest.Method = "POST";
myRequest.CookieContainer = ccc;
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();
// Send the data.
newStream.Write(data, 0, data.Length);
newStream.Close();
// Get response
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.Default);
string content = reader.ReadToEnd();
[/align]