62,266
社区成员
发帖
与我相关
我的任务
分享
protected void Button1_Click(object sender, EventArgs e)
{
string url = "http://passport.csdn.net/UserLogin.aspx?from=http://community.csdn.net/";
string zh = TextBox1.Text;//账号
string mm = TextBox2.Text;//密码
string yzm = TextBox3.Text;//验证码
string postdata = "";
//请求
HttpWebRequest hwr = (HttpWebRequest)HttpWebRequest.Create(url);
hwr.Referer = "http://passport.csdn.net/UserLogin.aspx?from=http://community.csdn.net/";
hwr.ContentType = "application/x-www-form-urlencoded";
hwr.ContentLength = postdata.Length;
hwr.Method = "POST";
hwr.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.19) Gecko/2010031422 Firefox/3.0.19 (.NET CLR 3.5.30729)";
hwr.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
hwr.CookieContainer = this._cookies;
Stream requestStream = hwr.GetRequestStream();
StreamWriter writer = writer = new StreamWriter(requestStream);
writer.Write(postdata);
writer.Flush();
writer.Close();
requestStream.Close();
//响应
HttpWebResponse response = (HttpWebResponse)hwr.GetResponse();//
string qqurl=response.ResponseUri.ToString();//获取返回相应的url
}
