|
|
|
ส่ง Parameter จาก C# Console App ไป Web .ASPX(C#.Net) มีคำสั่งไหนบ้างครับ |
|
|
|
|
|
|
|
ใช้พวก WebClient ครับ เช่น
Code (C#)
private void MainPage_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
string url = "http://localhost/myphp/post.php";
Uri uri = new Uri(url, UriKind.Absolute);
StringBuilder postData = new StringBuilder();
postData.AppendFormat("{0}={1}", "Name", HttpUtility.UrlEncode("Weerachai Nukitram"));
postData.AppendFormat("&{0}={1}", "Email", HttpUtility.UrlEncode("[email protected]"));
postData.AppendFormat("&{0}={1}", "Tel", HttpUtility.UrlEncode("0819876107"));
WebClient client = default(WebClient);
client = new WebClient();
client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
client.Headers[HttpRequestHeader.ContentLength] = postData.Length.ToString();
client.UploadStringCompleted += client_UploadStringCompleted;
client.UploadProgressChanged += client_UploadProgressChanged;
client.UploadStringAsync(uri, "POST", postData.ToString());
}
private void client_UploadProgressChanged(object sender, UploadProgressChangedEventArgs e)
{
this.txtResult.Text = "Uploading.... " + e.ProgressPercentage + "%";
}
private void client_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
{
this.txtResult.Text = e.Result;
}
|
|
|
|
|
Date :
2014-04-17 10:27:15 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|