c :

2013-03-11 1 views
1

"System.Net.NetworkCredential"에서 오버로드되지 않은 webclient로 웹 페이지 인증을 입력하십시오. "과부하"되지 않은 인증이 필요한 웹 사이트 콘텐츠에 연결하고 다운로드하려고합니다.c :

옵션은 다음과 같습니다

  • 사용자
  • 사용자 + 비밀번호,
  • 사용자 + 비밀번호 + 도메인

I 사용자 + 가입자 + 암호가 필요합니다. 이 자격 증명을 어떻게 통과시킬 수 있습니까?

코드 :

내가 문제를 해결하는 방법
WebClient client = new WebClient(); 
public void search() 
{ 
     client.Credentials = new System.Net.NetworkCredential(username, subscriber, password); //not really exist 
     Byte[] pageData = client.DownloadData("https://example.com/"); 
... 
} 
+0

'https : // thewebsite.i.need /'가 무엇인지 알려주는 것은 당신을 도울 수있는 누군가에게 먼 길을 간다. – tomfanning

+0

죄송합니다. 업무 관련 내부 웹 사이트입니다. 당신은 그것에 접근 할 필요가 없습니다 –

+1

@ModusRoeiPonens 아래의이 질문에 대한 답변을 추가하고 우리가 모든 이익을 누릴 수 있도록 며칠 이내에 수락 할 수있을 때 그것을 받아주십시오. – rhughes

답변

1

: 이 improvedWebClient 클래스와 POST 방법을 사용, 즉 WebClient를하지만, 쿠키를 저장 한 것과 같습니다. 당신은 그것을 here 찾을 수 있습니다.
코드 : 도움말들에 대한

ImprovedWebClient wc = new ImprovedWebClient(); 
wc.DownloadData("https://theWebSite.com"); //to enter home page and get cookie 
string URI = "https://theWebSite.com/authenticate"; //the login page 
string myParameters = "user=theUserName&subscriber_number=1234-5678&password=myPassword&commit=LogIn"; //the parameters for the website 
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; 
wc.UploadString(URI, myParameters); 

감사합니다.