|
我拦截下来的请求包如下图:
第一个参数名应该是j_password.
第一个参数名应该是:j_password
请问那个乱码是从哪里来的?怎么处理才行。
//postdata
string data = string.Format("j_password={0}&j_username={1}&j_captcha_response={2}", psw, name, yzm);
//请求
string ans = Model.Variable.dd.HttpPost("http://ecar.95590.cn/ecar/j_spring_security_check", data, "http://ecar.95590.cn/ecar/view/ecar/login/login.jsp");
//dd.HttpPost
public string HttpPost(string Url, string postDataStr, string referer)
{
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(Url);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.CookieContainer = this.cookie;
request.Referer = referer;
StreamWriter writer = new StreamWriter(request.GetRequestStream(), Encoding.GetEncoding("utf-8"));
writer.Write(postDataStr);
writer.Close();
HttpWebResponse response = null;
try
{
this.SetCertificatePolicy();
response = (HttpWebResponse) request.GetResponse();
}
catch (Exception)
{
}
if (response != null)
{
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream, Encoding.GetEncoding("utf-8"));
string str = reader.ReadToEnd();
reader.Close();
responseStream.Close();
return str.Replace(" ", "").Replace("\r\n", "").Replace("\t", "");
}
return "error";
}
|
|