1
我正在嘗試使用httpwebrequest對象登錄到www.diary.com。但是,它總是無法登錄,並不斷給我回登錄頁面。任何人都可以啓發我什麼是錯誤的?c#httpwebrequest憑證問題
我的代碼如下:
// 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(@"[email protected]", "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);