我正在尝试使用httpwebrequest对象登录www.diary.com.但是,它总是无法登录,并不断给我回登录页面.有人可以告诉我什么是错的?
我的代码如下:
// prepare the web page we will be asking for
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create(@"http://diary.com/events/agenda");
request.ContentType = "text/html";
request.Credentials = new NetworkCredential(@"user@hotmail.com", "password");
request.AllowAutoRedirect = true;
request.Referer = @"http://diary.com/";
// execute the request
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();
// we will read data via the response stream
Stream resStream = response.GetResponseStream();
// set the WebBrowser object documentStream to the response stream
myWB.DocumentStream = resStream;
// simply tell me the title of the webpage
MessageBox.Show(myWB.Document.Title);
Run Code Online (Sandbox Code Playgroud)