我尝试了多次使用httprequest但没有工作...... 这是我的代码
//POSTDATA=inputUserName=dmsang&inputPassword=123456789
string strURL;
string strPostData = "";
string strResult;
HttpWebResponse webrespond;
HttpWebRequest webresquest;
StreamReader sr;
StreamWriter sw;
//======================================
//string a = form1.FindControl("chogochu");
//set url to post
strURL = "http://up.4share.vn/?act=login";
//post some data
strPostData = "inputUserName=dmsang&inputPassword=123456789";
webresquest = (HttpWebRequest)WebRequest.Create(strURL);
webresquest.Method = "POST";
webresquest.Referer = strURL;
webresquest.ContentType = "application/x-www-form-urlencoded";
webresquest.ContentLength = strPostData.Length;
//post data
sw = new StreamWriter(webresquest.GetRequestStream());
sw.Write(strPostData);
sw.Close();
//read the returned data
webrespond = (HttpWebResponse)webresquest.GetResponse();
sr = new StreamReader(webrespond.GetResponseStream());
strResult = sr.ReadToEnd();
sr.Close();
//write the result
TextBox1.Text = strResult;
如果响应标题中的位置= /?act = accinfo是登录成功
答案 0 :(得分:0)
您必须检查响应(strResult
和webrespond.Headers
)以查看错误。问题应该显示在那里的某个地方,你找到的将决定下一步需要采取的步骤。