2017-02-19 2 views
0

을 로그인 리디렉션 계속에 "https://uptobox.com/?op=my_account"페이지에 로그인하지만 로그인 페이지 에 저를 리디렉션 유지 후 나는내가 내 프로그램을 리디렉션하기 위해 노력하고있어 페이지를

request.AllowAutoRedirect = true; 

을 시도하고 로그인 쿠키를 사용하여 리디렉션하지만 문제는 로그인 후 세트 - 쿠키 헤더에 생성됩니다 작동하지 내가 & 내가 승리 양식 응용 프로그램을 사용하고 리디렉션 요청으로 그것을 주입하는 방법을 모르는의 요청에

  ASCIIEncoding encoding = new ASCIIEncoding(); 
      string postData = "login=" + username + "&password=" + pw +"&op=login"; 
      byte[] data = encoding.GetBytes(postData); 
      HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://login.uptobox.com/logarithme"); 
      request.Method = "POST"; 
      CookieContainer mycoockie = new CookieContainer(); 
      request.CookieContainer = mycoockie; 
      request.ContentType = "application/x-www-form-urlencoded"; 
      request.ContentLength = data.Length; 
      Stream stream = request.GetRequestStream(); 
      stream.Write(data, 0, data.Length); 
      stream.Close(); 
      WebResponse response = request.GetResponse(); 
      stream = response.GetResponseStream(); 
      StreamReader sr = new StreamReader(stream); 
      string source_code = sr.ReadToEnd(); 
+0

컨텍스트를 시도 했습니까? – Svek

+0

나는 asp.net와 함께 일하고 있지 않다. –

답변

0

대답은 : 성공한 로그인의 헤더 응답에서 생성 된 세트 쿠키를 새 요청에 추가하는 것입니다.

request.Headers.Add("cookie", "value"); 
관련 문제