サイトへのログインに問題があります。これが私のコードです(Visual Studio 2010、フォームアプリケーション)(また、私は初心者です)
フォームに何を追加すればよいですか? 作ってみましたが出来ませんでした。
HttpWebRequest request;
HttpWebResponse response;
CookieContainer cookies;
string url = string.Format("http://extabit.com/login.jsp.login={0}&passwd={1}", cboUserName.Text, txtPassWord.Text);
request = (HttpWebRequest)WebRequest.Create(url);
request.AllowAutoRedirect = false;
request.CookieContainer = new CookieContainer();
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode != HttpStatusCode.Found)
{
//ToDo: if the page wasn't found raise Exception
//instead of this textmessage
MessageBox.Show("Something Wrong");
response.Close();
request.KeepAlive = false;
return;
}
cookies = request.CookieContainer;
response.Close();
request = (HttpWebRequest)WebRequest.Create(http://extabit.com);
request.AllowAutoRedirect = false;
request.CookieContainer = cookies;
response = (HttpWebResponse)request.GetResponse();
using (Stream s = response.GetResponseStream())
{
StreamReader sr = new StreamReader(s);
string line;
while (!sr.EndOfStream)
{
//todo read the page contents
}