Fos*_*erZ -1 c# httpwebrequest httpwebresponse
我有以下代码登录到POST http://www.160by2.com/logincheck.aspx?iamindian=
这个网址,我的问题是我无法登录,当我使用Fiddler调试它时,我看不到ne cookie认为我正在使用CookieContainer
类,这里我在c#中使用Windows应用程序
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.160by2.com/logincheck.aspx?iamindian=");
string PostData = string.Format("htxt_UserName={0}&txt_Passwd={1}&txt_pop=&s=&d=&cmdSubmit=&namenumber={2}&strclf=&strshareuser=&ucountry=&ucode=&ucity=&uregion=", txtMobile.Text, txtPassword.Text, "1");
CookieContainer cookie = new CookieContainer();
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.Referer = "http://www.160by2.com";
request.CookieContainer = cookie;
StreamWriter sWriter = new StreamWriter(request.GetRequestStream());
sWriter.Write(PostData);
sWriter.Close();
request.GetResponse().Close();
//some more code is here for further posting but above code can't login so below code is also not working
Run Code Online (Sandbox Code Playgroud)
我跟着这个,发帖但是它对我没有帮助..请帮帮我,这里我的错误..
那是真的,因为
CookieContainer cookie = new CookieContainer();
Run Code Online (Sandbox Code Playgroud)
你没有把任何东西放到你的cookie容器里.
使用Add方法将实际值放入cookie
container.Add(new Uri("http://yoursite"), new Cookie("name", "value"));
Run Code Online (Sandbox Code Playgroud)
并再次发布.
归档时间: |
|
查看次数: |
4686 次 |
最近记录: |