WebClient.UploadValues 메서드

정의

지정된 URI를 사용하여 리소스에 이름/값 컬렉션을 업로드합니다.

오버로드

UploadValues(String, NameValueCollection)

지정된 URI로 식별되는 리소스에 지정된 이름/값 컬렉션을 업로드합니다.

UploadValues(Uri, NameValueCollection)

지정된 URI로 식별되는 리소스에 지정된 이름/값 컬렉션을 업로드합니다.

UploadValues(String, String, NameValueCollection)

지정된 메서드를 사용하여, 지정된 URI로 식별되는 리소스에 지정된 이름/값 컬렉션을 업로드합니다.

UploadValues(Uri, String, NameValueCollection)

지정된 메서드를 사용하여, 지정된 URI로 식별되는 리소스에 지정된 이름/값 컬렉션을 업로드합니다.

UploadValues(String, NameValueCollection)

Source:
WebClient.cs
Source:
WebClient.cs
Source:
WebClient.cs

지정된 URI로 식별되는 리소스에 지정된 이름/값 컬렉션을 업로드합니다.

public:
 cli::array <System::Byte> ^ UploadValues(System::String ^ address, System::Collections::Specialized::NameValueCollection ^ data);
public byte[] UploadValues (string address, System.Collections.Specialized.NameValueCollection data);
member this.UploadValues : string * System.Collections.Specialized.NameValueCollection -> byte[]
Public Function UploadValues (address As String, data As NameValueCollection) As Byte()

매개 변수

address
String

컬렉션을 받을 리소스의 URI입니다.

data
NameValueCollection

리소스에 보낼 NameValueCollection입니다.

반환

Byte[]

리소스의 응답 본문이 포함된 Byte 배열입니다.

예외

address 매개 변수가 null인 경우

또는

data 매개 변수가 null인 경우

BaseAddressaddress를 조합하여 만든 URI가 잘못된 경우

또는

datanull입니다.

또는

리소스를 호스팅하는 서버에서 응답이 없는 경우

또는

스트림을 여는 동안 오류가 발생한 경우

또는

Content-type 헤더가 null 또는 "application/x-www-form-urlencoded"가 아닌 경우

예제

다음 코드 예제에서는 사용자(이름, 나이 및 주소)에서 정보를 수집하고 를 사용하여 UploadValues값을 서버에 게시합니다. 서버의 모든 응답이 콘솔에 표시됩니다.

Console::Write( "\nPlease enter the URI to post data to: " );
String^ uriString = Console::ReadLine();

// Create a new WebClient instance.
WebClient^ myWebClient = gcnew WebClient;

// Create a new NameValueCollection instance to hold some custom parameters to be posted to the URL.
NameValueCollection^ myNameValueCollection = gcnew NameValueCollection;

Console::WriteLine( "Please enter the following parameters to be posted to the URL" );
Console::Write( "Name: " );
String^ name = Console::ReadLine();

Console::Write( "Age: " );
String^ age = Console::ReadLine();

Console::Write( "Address: " );
String^ address = Console::ReadLine();

// Add necessary parameter/value pairs to the name/value container.
myNameValueCollection->Add( "Name", name );
myNameValueCollection->Add( "Address", address );
myNameValueCollection->Add( "Age", age );

Console::WriteLine( "\nUploading to {0} ...", uriString );
// 'The Upload(String, NameValueCollection)' implicitly method sets HTTP POST as the request method.
array<Byte>^ responseArray = myWebClient->UploadValues( uriString, myNameValueCollection );

// Decode and display the response.
Console::WriteLine( "\nResponse received was :\n {0}", Encoding::ASCII->GetString( responseArray ) );
Console.Write("\nPlease enter the URI to post data to : ");
string uriString = Console.ReadLine();

// Create a new WebClient instance.
WebClient myWebClient = new WebClient();

// Create a new NameValueCollection instance to hold some custom parameters to be posted to the URL.
NameValueCollection myNameValueCollection = new NameValueCollection();

Console.WriteLine("Please enter the following parameters to be posted to the URL");
Console.Write("Name:");
string name = Console.ReadLine();

Console.Write("Age:");
string age = Console.ReadLine();

Console.Write("Address:");
string address = Console.ReadLine();

// Add necessary parameter/value pairs to the name/value container.
myNameValueCollection.Add("Name",name);            
myNameValueCollection.Add("Address",address);
myNameValueCollection.Add("Age",age);

Console.WriteLine("\nUploading to {0} ...",  uriString);
// 'The Upload(String,NameValueCollection)' implicitly method sets HTTP POST as the request method.            
byte[] responseArray = myWebClient.UploadValues(uriString,myNameValueCollection);

// Decode and display the response.
Console.WriteLine("\nResponse received was :\n{0}",Encoding.ASCII.GetString(responseArray));
Console.Write(ControlChars.Cr + "Please enter the URI to post data to : ")
Dim uriString As String = Console.ReadLine()
' Create a new WebClient instance.
Dim myWebClient As New WebClient()
' Create a new NameValueCollection instance to hold some custom parameters to be posted to the URL.
Dim myNameValueCollection As New NameValueCollection()
Console.WriteLine("Please enter the following parameters to be posted to the URL:")
Console.Write("Name:")
Dim name As String = Console.ReadLine()

Console.Write("Age:")
Dim age As String = Console.ReadLine()

Console.Write("Address:")
Dim address As String = Console.ReadLine()

' Add necessary parameter/value pairs to the name/value container.
myNameValueCollection.Add("Name", name)
myNameValueCollection.Add("Address", address)
myNameValueCollection.Add("Age", age)

Console.WriteLine(ControlChars.Cr + "Uploading to {0} ...", uriString)
' The Upload(String,NameValueCollection)' method implicitly sets the HTTP POST as the request method.			
Dim responseArray As Byte() = myWebClient.UploadValues(uriString, myNameValueCollection)

' Decode and display the response.
Console.WriteLine(ControlChars.Cr + "Response received was :" + ControlChars.Cr + "{0}", Encoding.ASCII.GetString(responseArray))

설명

메서드는 UploadValues 서버에 을 보냅니다 NameValueCollection . 이 메서드는 데이터를 업로드하는 동안 차단합니다. 서버의 응답을 기다리는 동안 실행을 계속하려면 메서드 중 UploadValuesAsync 하나를 사용합니다.

서버에서 기본 요청을 이해하지 못하는 경우 기본 프로토콜 클래스는 어떤 일이 발생하는지 결정합니다. 일반적으로 WebException 는 오류를 나타내기 위해 속성이 설정된 상태에서 Status throw됩니다.

Content-type 헤더가 null이면 메서드는 UploadValues 이를 "application/x-www-form-urlencoded"로 설정합니다.

속성이 BaseAddress 빈 문자열("")이 아니고 address 절대 URI를 포함하지 않는 경우 는 요청된 데이터의 절대 URI address 를 형성하기 위해 와 BaseAddress 결합된 상대 URI여야 합니다. 속성이 QueryString 빈 문자열이 아니면 에 추가됩니다 address.

이 메서드는 STOR 명령을 사용하여 FTP 리소스를 업로드합니다. HTTP 리소스의 경우 POST 메서드가 사용됩니다.

참고

애플리케이션에 네트워크 추적을 사용하도록 설정하면 이 멤버에서 추적 정보를 출력합니다. 자세한 내용은 .NET Framework 네트워크 추적을 참조하세요.

적용 대상

UploadValues(Uri, NameValueCollection)

Source:
WebClient.cs
Source:
WebClient.cs
Source:
WebClient.cs

지정된 URI로 식별되는 리소스에 지정된 이름/값 컬렉션을 업로드합니다.

public:
 cli::array <System::Byte> ^ UploadValues(Uri ^ address, System::Collections::Specialized::NameValueCollection ^ data);
public byte[] UploadValues (Uri address, System.Collections.Specialized.NameValueCollection data);
member this.UploadValues : Uri * System.Collections.Specialized.NameValueCollection -> byte[]
Public Function UploadValues (address As Uri, data As NameValueCollection) As Byte()

매개 변수

address
Uri

컬렉션을 받을 리소스의 URI입니다.

data
NameValueCollection

리소스에 보낼 NameValueCollection입니다.

반환

Byte[]

리소스의 응답 본문이 포함된 Byte 배열입니다.

예외

address 매개 변수가 null인 경우

또는

data 매개 변수가 null인 경우

BaseAddressaddress를 조합하여 만든 URI가 잘못된 경우

또는

datanull입니다.

또는

리소스를 호스팅하는 서버에서 응답이 없는 경우

또는

스트림을 여는 동안 오류가 발생한 경우

또는

Content-type 헤더가 null 또는 "application/x-www-form-urlencoded"가 아닌 경우

설명

메서드는 UploadValues 서버에 을 보냅니다 NameValueCollection . 이 메서드는 데이터를 업로드하는 동안 차단합니다. 서버의 응답을 기다리는 동안 실행을 계속하려면 메서드 중 UploadValuesAsync 하나를 사용합니다.

서버에서 기본 요청을 이해하지 못하는 경우 기본 프로토콜 클래스는 어떤 일이 발생하는지 결정합니다. 일반적으로 WebException 는 오류를 나타내기 위해 속성이 설정된 상태에서 Status throw됩니다.

Content-type 헤더가 null이면 메서드는 UploadValues 이를 "application/x-www-form-urlencoded"로 설정합니다.

속성이 BaseAddress 빈 문자열("")이 아니고 address 절대 URI를 포함하지 않는 경우 는 요청된 데이터의 절대 URI address 를 형성하기 위해 와 BaseAddress 결합된 상대 URI여야 합니다. 속성이 QueryString 빈 문자열이 아니면 에 추가됩니다 address.

이 메서드는 STOR 명령을 사용하여 FTP 리소스를 업로드합니다. HTTP 리소스의 경우 POST 메서드가 사용됩니다.

참고

애플리케이션에 네트워크 추적을 사용하도록 설정하면 이 멤버에서 추적 정보를 출력합니다. 자세한 내용은 .NET Framework 네트워크 추적을 참조하세요.

적용 대상

UploadValues(String, String, NameValueCollection)

Source:
WebClient.cs
Source:
WebClient.cs
Source:
WebClient.cs

지정된 메서드를 사용하여, 지정된 URI로 식별되는 리소스에 지정된 이름/값 컬렉션을 업로드합니다.

public:
 cli::array <System::Byte> ^ UploadValues(System::String ^ address, System::String ^ method, System::Collections::Specialized::NameValueCollection ^ data);
public byte[] UploadValues (string address, string? method, System.Collections.Specialized.NameValueCollection data);
public byte[] UploadValues (string address, string method, System.Collections.Specialized.NameValueCollection data);
member this.UploadValues : string * string * System.Collections.Specialized.NameValueCollection -> byte[]
Public Function UploadValues (address As String, method As String, data As NameValueCollection) As Byte()

매개 변수

address
String

컬렉션을 받을 리소스의 URI입니다.

method
String

리소스에 파일을 보내는 데 사용되는 HTTP 메서드입니다. null인 경우 http의 기본값은 POST이고 ftp의 기본값은 STOR입니다.

data
NameValueCollection

리소스에 보낼 NameValueCollection입니다.

반환

Byte[]

리소스의 응답 본문이 포함된 Byte 배열입니다.

예외

address 매개 변수가 null인 경우

또는

data 매개 변수가 null인 경우

BaseAddressaddress를 조합하여 만든 URI가 잘못된 경우

또는

datanull입니다.

또는

스트림을 여는 동안 오류가 발생한 경우

또는

리소스를 호스팅하는 서버에서 응답이 없는 경우

또는

Content-type 헤더 값이 nullapplication/x-www-form-urlencoded가 아닌 경우

예제

다음 코드 예제에서는 사용자(이름, 나이 및 주소)에서 정보를 수집하고 를 사용하여 UploadValues값을 서버에 게시합니다. 서버의 모든 응답이 콘솔에 표시됩니다.

Console::Write( "\nPlease enter the URL to post data to: " );
String^ uriString = Console::ReadLine();

// Create a new WebClient instance.
WebClient^ myWebClient = gcnew WebClient;

// Create a new NameValueCollection instance to hold some custom parameters to be posted to the URL.
NameValueCollection^ myNameValueCollection = gcnew NameValueCollection;

Console::WriteLine( "Please enter the following parameters to be posted to the URI" );
Console::Write( "Name: " );
String^ name = Console::ReadLine();

Console::Write( "Age: " );
String^ age = Console::ReadLine();

Console::Write( "Address: " );
String^ address = Console::ReadLine();

// Add necessary parameter/value pairs to the name/value container.
myNameValueCollection->Add( "Name", name );
myNameValueCollection->Add( "Address", address );
myNameValueCollection->Add( "Age", age );
Console::WriteLine( "\nUploading to {0} ...", uriString );

// Upload the NameValueCollection.
array<Byte>^ responseArray = myWebClient->UploadValues( uriString, "POST", myNameValueCollection );

// Decode and display the response.
Console::WriteLine( "\nResponse received was :\n {0}", Encoding::ASCII->GetString( responseArray ) );
Console.Write("\nPlease enter the URL to post data to : ");
string uriString = Console.ReadLine();

// Create a new WebClient instance.
WebClient myWebClient = new WebClient();

// Create a new NameValueCollection instance to hold some custom parameters to be posted to the URL.
NameValueCollection myNameValueCollection = new NameValueCollection();

Console.WriteLine("Please enter the following parameters to be posted to the URI");
Console.Write("Name:");
string name = Console.ReadLine();

Console.Write("Age:");
string age = Console.ReadLine();

Console.Write("Address:");
string address = Console.ReadLine();

// Add necessary parameter/value pairs to the name/value container.
myNameValueCollection.Add("Name",name);			
myNameValueCollection.Add("Address",address);
myNameValueCollection.Add("Age",age);
Console.WriteLine("\nUploading to {0} ...",  uriString);

// Upload the NameValueCollection.
byte[] responseArray = myWebClient.UploadValues(uriString,"POST",myNameValueCollection);

// Decode and display the response.
Console.WriteLine("\nResponse received was :\n{0}",Encoding.ASCII.GetString(responseArray));
Console.Write(ControlChars.Cr + "Please enter the URL to post data to : ")
Dim uriString As String = Console.ReadLine()

' Create a new WebClient instance.
Dim myWebClient As New WebClient()

' Create a new NameValueCollection instance to hold some custom parameters to be posted to the URL.
Dim myNameValueCollection As New NameValueCollection()

Console.WriteLine("Please enter the following parameters to be posted to the Url")
Console.Write("Name:")
Dim name As String = Console.ReadLine()

Console.Write("Age:")
Dim age As String = Console.ReadLine()

Console.Write("Address:")
Dim address As String = Console.ReadLine()

' Add necessary parameter/value pairs to the name/value container.
myNameValueCollection.Add("Name", name)
myNameValueCollection.Add("Address", address)
myNameValueCollection.Add("Age", age)

Console.WriteLine(ControlChars.Cr + "Uploading to {0} ...", uriString)

' Upload the NameValueCollection.
Dim responseArray As Byte() = myWebClient.UploadValues(uriString, "POST", myNameValueCollection)

' Decode and display the response.
Console.WriteLine(ControlChars.Cr + "Response received was :" + ControlChars.Cr + "{0}", Encoding.ASCII.GetString(responseArray))

설명

메서드는 UploadValuesNameValueCollection 매개 변수에 지정된 메서드를 사용하여 리소스에 을 method 보내고 서버의 모든 응답을 반환합니다. 이 메서드는 데이터를 업로드하는 동안 차단합니다. 서버의 응답을 기다리는 동안 실행을 계속하려면 메서드 중 UploadValuesAsync 하나를 사용합니다.

헤더가 이 Content-type 면 메서드는 헤더를 UploadValuesapplication/x-www-form-urlencoded설정합니다.null

매개 변수가 method 서버에서 인식할 수 없는 동사를 지정하는 경우 기본 프로토콜 클래스는 어떤 일이 발생하는지 결정합니다. 일반적으로 WebException 는 오류를 나타내기 위해 속성이 설정된 상태에서 Status throw됩니다.

속성이 BaseAddress 빈 문자열("")이 아니고 address 절대 URI를 포함하지 않는 경우 는 요청된 데이터의 절대 URI address 를 형성하기 위해 와 BaseAddress 결합된 상대 URI여야 합니다. 속성이 QueryString 빈 문자열이 아니면 에 추가됩니다 address.

참고

애플리케이션에 네트워크 추적을 사용하도록 설정하면 이 멤버에서 추적 정보를 출력합니다. 자세한 내용은 .NET Framework 네트워크 추적을 참조하세요.

적용 대상

UploadValues(Uri, String, NameValueCollection)

Source:
WebClient.cs
Source:
WebClient.cs
Source:
WebClient.cs

지정된 메서드를 사용하여, 지정된 URI로 식별되는 리소스에 지정된 이름/값 컬렉션을 업로드합니다.

public:
 cli::array <System::Byte> ^ UploadValues(Uri ^ address, System::String ^ method, System::Collections::Specialized::NameValueCollection ^ data);
public byte[] UploadValues (Uri address, string? method, System.Collections.Specialized.NameValueCollection data);
public byte[] UploadValues (Uri address, string method, System.Collections.Specialized.NameValueCollection data);
member this.UploadValues : Uri * string * System.Collections.Specialized.NameValueCollection -> byte[]
Public Function UploadValues (address As Uri, method As String, data As NameValueCollection) As Byte()

매개 변수

address
Uri

컬렉션을 받을 리소스의 URI입니다.

method
String

리소스에 파일을 보내는 데 사용되는 HTTP 메서드입니다. null인 경우 http의 기본값은 POST이고 ftp의 기본값은 STOR입니다.

data
NameValueCollection

리소스에 보낼 NameValueCollection입니다.

반환

Byte[]

리소스의 응답 본문이 포함된 Byte 배열입니다.

예외

address 매개 변수가 null인 경우

또는

data 매개 변수가 null인 경우

BaseAddressaddress를 조합하여 만든 URI가 잘못된 경우

또는

datanull입니다.

또는

스트림을 여는 동안 오류가 발생한 경우

또는

리소스를 호스팅하는 서버에서 응답이 없는 경우

또는

Content-type 헤더 값이 nullapplication/x-www-form-urlencoded가 아닌 경우

설명

메서드는 UploadValuesNameValueCollection 매개 변수에 지정된 메서드를 사용하여 리소스에 을 method 보내고 서버의 모든 응답을 반환합니다. 이 메서드는 데이터를 업로드하는 동안 차단합니다. 서버의 응답을 기다리는 동안 실행을 계속하려면 메서드 중 UploadValuesAsync 하나를 사용합니다.

헤더가 이 Content-type 면 메서드는 헤더를 UploadValuesapplication/x-www-form-urlencoded설정합니다.null

매개 변수가 method 서버에서 인식할 수 없는 동사를 지정하는 경우 기본 프로토콜 클래스는 어떤 일이 발생하는지 결정합니다. 일반적으로 WebException 는 오류를 나타내기 위해 속성이 설정된 상태에서 Status throw됩니다.

속성이 BaseAddress 빈 문자열("")이 아니고 address 절대 URI를 포함하지 않는 경우 는 요청된 데이터의 절대 URI address 를 형성하기 위해 와 BaseAddress 결합된 상대 URI여야 합니다. 속성이 QueryString 빈 문자열이 아니면 에 추가됩니다 address.

참고

애플리케이션에 네트워크 추적을 사용하도록 설정하면 이 멤버에서 추적 정보를 출력합니다. 자세한 내용은 .NET Framework 네트워크 추적을 참조하세요.

적용 대상