WebClient.UseDefaultCredentials 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
요청에 Boolean을 보낼지 여부를 제어하는 DefaultCredentials 값을 가져오거나 설정합니다.
public:
property bool UseDefaultCredentials { bool get(); void set(bool value); };
public bool UseDefaultCredentials { get; set; }
member this.UseDefaultCredentials : bool with get, set
Public Property UseDefaultCredentials As Boolean
속성 값
기본 자격 증명이 사용되면 true
이고, 그렇지 않으면 false
입니다. 기본값은 false
입니다.
예제
다음 코드 예제에서는이 속성을 설정 하는 방법을 보여 줍니다.
// Sample call: UploadFileInBackground3("http://www.contoso.com/fileUpload.aspx", "data.txt")
void UploadFileInBackground3( String^ address, String^ fileName )
{
WebClient^ client = gcnew WebClient;
Uri ^uri = gcnew Uri(address);
client->UseDefaultCredentials = true;
client->UploadFileCompleted += gcnew UploadFileCompletedEventHandler( UploadFileCallback2 );
client->UploadFileAsync( uri, fileName );
Console::WriteLine( "File upload started." );
}
// Sample call: UploadFileInBackground3("http://www.contoso.com/fileUpload.aspx", "data.txt")
public static void UploadFileInBackground3(string address, string fileName)
{
WebClient client = new WebClient();
Uri uri = new Uri(address);
client.UseDefaultCredentials = true;
client.UploadFileCompleted += new UploadFileCompletedEventHandler(UploadFileCallback2);
client.UploadFileAsync(uri, fileName);
Console.WriteLine("File upload started.");
}
' Sample call: UploadFileInBackground3("http:' www.contoso.com/fileUpload.aspx", "data.txt")
Public Shared Sub UploadFileInBackground3(ByVal address As String, ByVal fileName As String)
Dim client As WebClient = New WebClient()
Dim uri as Uri = New Uri(address)
client.UseDefaultCredentials = True
AddHandler client.UploadFileCompleted, AddressOf UploadFileCallback2
client.UploadFileAsync(uri, fileName)
Console.WriteLine("File upload started.")
End Sub
설명
이 개체의 요청이 서버에서 요청한 경우 현재 로그온한 사용자의 기본 자격 증명을 사용하여 인증해야 하는 경우 이 WebClient 속성을 true
로 설정합니다. 클라이언트 애플리케이션에 대 한 대부분의 시나리오에 필요한 동작은 이것이입니다. 이 속성을 사용 하는 대신 ASP.NET 애플리케이션과 같은 중간 계층 애플리케이션에 대 한 일반적으로 설정 된 Credentials 속성 대신 요청 클라이언트의 자격 증명을 합니다.
적용 대상
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기