public static string RequstJson(string username, string password)
{
string rtn;
string response;
Encoding e = Encoding.GetEncoding("GBK");
string param = "http://地址/iccty/essyu/session.do?" + HttpUtility.UrlEncode("userId", e) + "=" + HttpUtility.UrlEncode(username, e)
+ "&" + HttpUtility.UrlEncode("password", e) + "=" + HttpUtility.UrlEncode(password, e);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(param);
req.Method = "GET";
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream stream = resp.GetResponseStream();
//获取响应内容
using (StreamReader reader = new StreamReader(stream, e))
{
response = reader.ReadToEnd();
}
if (response.Contains("对不起,该用户不存在"))
{
rtn = "NO";
}
else
{
rtn = "YES";
}
return rtn;
}
}