2014-07-16 3 views
0

내 Windows Phone 8 앱에 텍스트가 포함 된 권한이 제한된 데이터베이스에서 데이터를 검색하려고합니다. 내 코드는 다음과 같습니다.Windows Phone 8의 보안 웹 사이트에서 데이터 가져 오기

private void Button_Click_1(object sender, RoutedEventArgs e) 
{ 
    WebClient wc = new WebClient(); 
    wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted); 
    wc.Credentials = new NetworkCredential("username", "password"); 
    wc.DownloadStringAsync(new Uri(@"http://www.siteaddress.com")); 
} 

void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) 
{ 
    string text = e.Result; 
} 

불행히도 다음 메시지가 표시됩니다. 내가 뭐 잘못하고 있니? 미리 감사드립니다. http://s30.postimg.org/yuc0mcb5t/pic.png

답변

0

서버에서 응답을 받기 위해 서버로 데이터를 보내려는 경우 서버에 대한 POST 데이터를 의미합니다.

void GetPosts(string UserID) 
    { 
     WebClient webclient = new WebClient(); 
     Uri uristring = new Uri("somelink.com"); 
     webclient.Headers["Content-Type"] = "application/x-www-form-urlencoded"; 
     string postJsonData = string.Empty; 
     postJsonData += "userId=" + UserID;//parameters you want to POST 
     webclient.UploadStringAsync(uristring, "POST", postJsonData); 
     webclient.UploadStringCompleted += webclient_UploadStringCompleted; 
    } 

    void webclient_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e) 
    { 
     .... // any code 
    } 
+0

실제로 어떤 문자열도 업로드하고 싶지 않습니다. 웹 사이트에 들어가면 설정된 사용자 이름과 암호를 입력하라는 메시지가 나타납니다. 그런 다음 텍스트가 긴 단일 페이지를 엽니 다. 내 앱이 웹 사이트에 로그인하고 미리 정의 된 사용자 이름과 비밀번호를 입력 한 다음 전체 텍스트 벽을 문자열로 복사 (= 웹 사이트 -> 앱으로 다운로드)하고 싶습니다. –

+0

이것은 업로드가 진행되는 것을 돕고, 업로드 문자열에서 서버의 응답을 얻습니다. 시도해 보라. –

관련 문제