string postData =string.Format( "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=/wEPDwULLTE1MzYzODg2NzZkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQtjaGtSZW1lbWJlcm1QYDyKKI9af4b67Mzq2xFaL9Bt&__EVENTVALIDATION=/wEWBQLWwpqPDQLyj/OQAgK3jsrkBALR55GJDgKC3IeGDE1m7t2mGlasoP1Hd9hLaFoI2G05&tbUserName={0}&tbPassword={1}&btnLogin=登 录&txtReturnUrl=http://home.cnblogs.com/",txtName.Text.Trim(),txtPwd.Text.Trim());
//这是cnblogs提交时的一些参数
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] data = encoding.GetBytes(postData);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://passport.cnblogs.com/login.aspx");
request.Method = "Post";
request.COntentType= "application/x-www-form-urlencoded";
request.COntentLength= data.Length;
request.KeepAlive = true;
request.COOKIECOntainer= container; //返回的COOKIE会附加在这个容器里面
//发送数据
Stream newStream = request.GetRequestStream();
newStream.Write(data, 0, data.Length);
HttpWebResponse respOnse= (HttpWebResponse)request.GetResponse();
newStream = response.GetResponseStream();
StreamReader reader = new StreamReader(newStream, Encoding.UTF8);
string text = reader.ReadToEnd();
reader.Close();
newStream.Close();