01.
using
System;
02.
using
System.Collections.Generic;
03.
using
System.IO;
04.
using
System.Linq;
05.
using
Windows.Devices.Geolocation;
06.
using
Windows.Foundation;
07.
using
Windows.Foundation.Collections;
08.
using
Windows.UI.Core;
09.
using
Windows.UI.Xaml;
10.
using
Windows.UI.Xaml.Controls;
11.
using
Windows.UI.Xaml.Controls.Primitives;
12.
using
Windows.UI.Xaml.Data;
13.
using
Windows.UI.Xaml.Input;
14.
using
Windows.UI.Xaml.Media;
15.
using
Windows.UI.Xaml.Navigation;
16.
17.
using
System.Net.Http;
18.
19.
20.
21.
namespace
WindowsStoreApps
22.
{
23.
/// <summary>
24.
/// An empty page that can be used on its own or navigated to within a Frame.
25.
/// </summary>
26.
///
27.
28.
public
sealed
partial
class
MainPage : Page
29.
{
30.
public
MainPage()
31.
{
32.
this
.InitializeComponent();
33.
}
34.
35.
private
async
void
btnSubmit_Click(
object
sender, RoutedEventArgs e)
36.
{
37.
38.
try
39.
{
40.
HttpClient http =
new
System.Net.Http.HttpClient();
41.
var content =
new
FormUrlEncodedContent(
new
[]
42.
{
43.
new
KeyValuePair<
string
,
string
>(
"pName"
,
this
.txtName.Text),
44.
new
KeyValuePair<
string
,
string
>(
"pSurname"
,
this
.txtSurname.Text)
45.
});
46.
47.
HttpResponseMessage response = await http.PostAsync(
this
.txtURL.Text, content);
48.
response.EnsureSuccessStatusCode();
49.
50.
51.
string
result =
string
.Empty;
52.
result = await response.Content.ReadAsStringAsync();
53.
54.
this
.lblResult.Text = result;
55.
56.
}
57.
catch
(HttpRequestException hre)
58.
{
59.
60.
}
61.
catch
(Exception ex)
62.
{
63.
64.
65.
}
66.
67.
}
68.
69.
}
70.
}