WebClient.UploadValues 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 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 배열입니다.
예외
BaseAddress 및 address
를 조합하여 만든 URI가 잘못된 경우
또는
data
은 null
입니다.
또는
리소스를 호스팅하는 서버에서 응답이 없는 경우
또는
스트림을 여는 동안 오류가 발생한 경우
또는
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 배열입니다.
예외
BaseAddress 및 address
를 조합하여 만든 URI가 잘못된 경우
또는
data
은 null
입니다.
또는
리소스를 호스팅하는 서버에서 응답이 없는 경우
또는
스트림을 여는 동안 오류가 발생한 경우
또는
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 배열입니다.
예외
BaseAddress 및 address
를 조합하여 만든 URI가 잘못된 경우
또는
data
은 null
입니다.
또는
스트림을 여는 동안 오류가 발생한 경우
또는
리소스를 호스팅하는 서버에서 응답이 없는 경우
또는
Content-type
헤더 값이 null
및 application/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
면 메서드는 헤더를 UploadValues 로 application/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 배열입니다.
예외
BaseAddress 및 address
를 조합하여 만든 URI가 잘못된 경우
또는
data
은 null
입니다.
또는
스트림을 여는 동안 오류가 발생한 경우
또는
리소스를 호스팅하는 서버에서 응답이 없는 경우
또는
Content-type
헤더 값이 null
및 application/x-www-form-urlencoded
가 아닌 경우
설명
메서드는 UploadValuesNameValueCollection 매개 변수에 지정된 메서드를 사용하여 리소스에 을 method
보내고 서버의 모든 응답을 반환합니다. 이 메서드는 데이터를 업로드하는 동안 차단합니다. 서버의 응답을 기다리는 동안 실행을 계속하려면 메서드 중 UploadValuesAsync 하나를 사용합니다.
헤더가 이 Content-type
면 메서드는 헤더를 UploadValues 로 application/x-www-form-urlencoded
설정합니다.null
매개 변수가 method
서버에서 인식할 수 없는 동사를 지정하는 경우 기본 프로토콜 클래스는 어떤 일이 발생하는지 결정합니다. 일반적으로 WebException 는 오류를 나타내기 위해 속성이 설정된 상태에서 Status throw됩니다.
속성이 BaseAddress 빈 문자열("")이 아니고 address
절대 URI를 포함하지 않는 경우 는 요청된 데이터의 절대 URI address
를 형성하기 위해 와 BaseAddress 결합된 상대 URI여야 합니다. 속성이 QueryString 빈 문자열이 아니면 에 추가됩니다 address
.
참고
애플리케이션에 네트워크 추적을 사용하도록 설정하면 이 멤버에서 추적 정보를 출력합니다. 자세한 내용은 .NET Framework 네트워크 추적을 참조하세요.
적용 대상
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기