public UploadValues ( System address, System data ) : byte[] | ||
address | System | |
data | System | |
return | byte[] |
using System; using System.Collections.Specialized; using System.Net; using System.Text; class Program { static void Main(string[] args) { string url = "http://example.com/api/login"; using (WebClient client = new WebClient()) { NameValueCollection formData = new NameValueCollection { { "username", "user123" }, { "password", "pass123" } }; byte[] response = client.UploadValues(url, "POST", formData); string result = Encoding.UTF8.GetString(response); Console.WriteLine(result); } } }
using System; using System.Collections.Specialized; using System.Net; using System.Text; class Program { static void Main(string[] args) { string url = "http://example.com/api/form"; using (WebClient client = new WebClient()) { NameValueCollection formData = new NameValueCollection { { "name", "John Doe" }, { "email", "[email protected]" }, { "message", "Hello World!" } }; byte[] response = client.UploadValues(url, "POST", formData); string result = Encoding.UTF8.GetString(response); Console.WriteLine(result); } } }In this example, we are sending a POST request to the server with the name, email, and message as parameters. The server will process the data and return the response. Package library: System.Net.WebClient is part of the .NET Framework Class Library.
public UploadValues ( System address, System data ) : byte[] | ||
address | System | |
data | System | |
return | byte[] |