日期:2014-05-16 浏览次数:20519 次
//转至相应系统验证绑定账号信息是否正确
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost:3958/WebR/Login.aspx");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
//验证条件
string data = "UserName=" + userName + "&pwd=" + pwd+ "&Ikey=1
request.ContentLength = data.Length;
//将POST信息附加到请求流中
StreamWriter writer = new StreamWriter(request.GetRequestStream(), Encoding.ASCII);
writer.Write(data);
writer.Flush();
//获取响应,并设置响应编码
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string encoding = response.ContentEncoding;
if (encoding == null || encoding.Length < 1)
encoding = "UTF-8"; //默认编码UTF-8
//读取响应流
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
data = reader.ReadToEnd();
reader.Dispose();
response.Close();
return WebRatmodel;