繁体   English   中英

使用ASP.net登录到其他网站

[英]Login to the other Website using ASP.net

我尝试使用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是登录成功

您将必须检查响应( strResultwebrespond.Headers )以查看错误是什么。 该问题应该显示在该位置的某个位置,您所发现的内容将决定下一步需要采取的步骤。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM