日期:2014-05-16 浏览次数:21073 次
string text = this.tbUser.Text;
string str = this.mtbPsw.Text;
string s = "username=" + HttpUtility.UrlEncode(text) + "&pwd=" + HttpUtility.UrlEncode(str);
byte[] bytes = Encoding.UTF8.GetBytes(s);
WebClient client = new WebClient();
client.Encoding = Encoding.GetEncoding("utf-8");
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
client.Headers.Set("Content-Type", "application/x-www-form-urlencoded");
byte[] buffer2 = null;
try
{
buffer2 = client.UploadData("http://localhost:4137/User_Login.ashx", "POST", bytes);
}
catch (Exception)
{
MessageBox.Show("服务器未响应");
return;
}
string xml = Encoding.UTF8.GetString(buffer2);