{"id":177,"date":"2012-10-11T15:44:22","date_gmt":"2012-10-11T15:44:22","guid":{"rendered":"http:\/\/www.rezafaisal.net\/?p=177"},"modified":"2012-11-04T13:03:54","modified_gmt":"2012-11-04T13:03:54","slug":"creating-simple-asp-net-mvc-web-api-to-be-accessed-by-windows-store-app","status":"publish","type":"post","link":"https:\/\/www.rezafaisal.net\/?p=177","title":{"rendered":"Creating Simple ASP.NET MVC Web API to be accessed by Windows Store App"},"content":{"rendered":"<p>Bagi pengguna Visual Studio 2012, maka akan menemukan ASP.NET MVC 4 pada template project web. Dan yang menarik adalah terdapat Web API sebagai salah satu fitur baru.<\/p>\n<p>ASP.NET Web API adalah framework yang memudahkan membuat HTTP Service agar dapat dikonsumsi oleh aplikasi web pada web browser, aplikasi desktop ataupun aplikasi mobile. Sehingga Web API sangat berguna sebagai sumber data pada native app seperti Windows Phone atau Windows Store app. Format output dari Web API dapat berupa XML, JSON ataupun yang lainnya.<\/p>\n<p>Pada artikel ini akan dijelaskan cara membuat HTTP Service yang sederhana untuk dikonsumsi oleh Windows Store App.<\/p>\n<p>{<em><strong>Create Web API Project<\/strong><\/em>}<\/p>\n<p>Berikut adalah langkah-langkah untuk membuat Web API Project.<\/p>\n<p>Pada Visual Studio 2012 pilih New Project, untuk membuat New Project dapat dilakukan dengan cara memilih File &gt; New &gt; Project. Kemudian pada pane Template pilih Installed Templates &gt; Visual C# &gt; Web &gt; ASP.NET MVC 4 Web Application kemudian klik OK.<\/p>\n<p><a href=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image14.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image_thumb15.png\" width=\"500\" height=\"319\" \/><\/a><\/p>\n<p>Selanjutnya pilih Web API pada pane New ASP.NET MVC 4 Project template, kemudian klik tombol OK.<\/p>\n<p><a href=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image15.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image_thumb16.png\" width=\"500\" height=\"452\" \/><\/a><\/p>\n<p>Selanjutnya akan dibuat Controller sederhana sebut saja HelloWorldContoller. Untuk membuat Controller ini maka klik kanan pada folder Controllers yang terdapat pada Solution Explorer, kemudian pilih Add &gt; Controller.<\/p>\n<p><a href=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image16.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image_thumb17.png\" width=\"500\" height=\"431\" \/><\/a><\/p>\n<p>Pada pane Add Controller, berikan nama HelloWorldController pada input Controller name. kemudian pilih Empty API Controller pada Scaffolding options &gt; Template, kemudian klik tombol Add.<\/p>\n<p><a href=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image17.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image_thumb18.png\" width=\"500\" height=\"325\" \/><\/a><\/p>\n<p>Selanjutnya tambahkan beberapa baris kode sehingga dapat dilihat isi file HelloWorldController.cs seperti berikut.<\/p>\n<div id=\"codeSnippetWrapper\" style=\"overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span style=\"color: #0000ff\">using<\/span> System;<span style=\"color: #0000ff\">using<\/span> System.Collections.Generic;<span style=\"color: #0000ff\">using<\/span> System.Linq;<span style=\"color: #0000ff\">using<\/span> System.Net;<span style=\"color: #0000ff\">using<\/span> System.Net.Http;<span style=\"color: #0000ff\">using<\/span> System.Web.Http;\r\n\r\n<span style=\"color: #0000ff\">namespace<\/span> MvcApplication2.Controllers{    <span style=\"color: #0000ff\">public<\/span> <span style=\"color: #0000ff\">class<\/span> HelloWorldController : ApiController    {        <span style=\"color: #008000\">\/\/ GET api\/values<\/span>        <span style=\"color: #0000ff\">public<\/span> <span style=\"color: #0000ff\">string<\/span> Get()        {            <span style=\"color: #0000ff\">return<\/span> <span style=\"color: #006080\">&quot;Hello World&quot;<\/span>;        }\r\n\r\n        <span style=\"color: #008000\">\/\/ GET api\/values\/5<\/span>        <span style=\"color: #0000ff\">public<\/span> <span style=\"color: #0000ff\">string<\/span> Get(<span style=\"color: #0000ff\">string<\/span> id)        {            <span style=\"color: #0000ff\">return<\/span> <span style=\"color: #006080\">&quot;Hello &quot;<\/span>+ id;        }    }}<\/pre>\n<\/div>\n<p>{<strong><em>Calling the Web API from the Browser<\/em><\/strong>}<\/p>\n<p>Untuk memanggil Web API yang telah dibuat maka pada menu di Visual Studio pilih Debug &gt; Start Debugging atau akan lebih cepat dengan cara menekan tombol F5. Maka secara otomatis akan dilakukan proses build dan bila sukses maka web browser default akan dijalankan. Hasilnya dapat dilihat seperti gambar berikut ini.<\/p>\n<p><a href=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image18.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image_thumb19.png\" width=\"500\" height=\"438\" \/><\/a><\/p>\n<p>Pada gambar di atas dapat dilihat alamat yang diakses adalah <a href=\"http:\/\/localhost:33011\">http:\/\/localhost:33011<\/a>. Untuk web API yang telah dibuat maka dapat dilakukan dengan cara mengakses alamat berikut dari web browser <a href=\"http:\/\/localhost:33011\/api\/HelloWorld\/\">http:\/\/localhost:33011\/api\/HelloWorld\/<\/a>.<\/p>\n<p><a href=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image19.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image_thumb20.png\" width=\"500\" height=\"365\" \/><\/a><\/p>\n<p>Respon dari request diatas berupa file HelloWorld.json dengan isi sebagai berikut :<\/p>\n<div id=\"codeSnippetWrapper\" style=\"overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span style=\"color: #006080\">&quot;Hello World&quot;<\/span><\/pre>\n<\/div>\n<p>Respon dari request tersebut akan berbeda jika menggunakan web browser Firefox. Pada Firefox akan didapati hasil seperti berikut.<\/p>\n<p><a href=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image20.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image_thumb21.png\" width=\"500\" height=\"304\" \/><\/a><\/p>\n<p>Selanjutnya akan dicoba request dengan alamat berikut http:\/\/localhost:33011\/api\/HelloWorld\/M Reza Faisal maka akan didapat hasil seperti berikut :<\/p>\n<p><a href=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image21.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image_thumb22.png\" width=\"500\" height=\"304\" \/><\/a><\/p>\n<p>{<strong><em>Calling the Web API from Windows Store App<\/em><\/strong>}<\/p>\n<p>Pada contoh di atas sudah diperlihatkan bagaimana cara memanggil Web API dari web browser dan sudah dilihat juga output dari Web API tersebut. Sekarang akan ditunjukkan bagaimana mengakses Web API dari Windows Store App.<\/p>\n<p>Terlebih dahulu tambahkan project pada solution. Langkah-langkah yang harus dilakukan adalah klik kanan pada Solution kemudian pilih Add &gt; New Project.<\/p>\n<p><a href=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image22.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image_thumb23.png\" width=\"500\" height=\"385\" \/><\/a><\/p>\n<p>Pada pane Add New Project pilih Installed &gt; Visual C# &gt; Windows Store &gt; Blank App (XAML).<\/p>\n<p><a href=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image23.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image_thumb24.png\" width=\"500\" height=\"319\" \/><\/a><\/p>\n<p>Pada input Name, berikan nama aplikasi yang diinginkan, misalnya HelloWorldApp. Kemudian klik tombol OK.<\/p>\n<p>Sekarang dapat dilihat terdapat project dengan nama HelloWorldApp pada Solution Explorer. Selanjutnya kita akan bekerja pada MainPage.xaml.<\/p>\n<p><a href=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image24.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image_thumb25.png\" width=\"300\" height=\"316\" \/><\/a><\/p>\n<p>Pada MainPage.xaml akan ditambahkan sebuah TextBlock dan Button, sehingga dapat dilihat antarmuka seperti berikut.<\/p>\n<p><a href=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image25.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image_thumb26.png\" width=\"450\" height=\"172\" \/><\/a><\/p>\n<p>Berikut adalah kode pada file MainPage.xaml.<\/p>\n<div id=\"codeSnippetWrapper\" style=\"overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span style=\"color: #0000ff\">&lt;<\/span><span style=\"color: #800000\">Page<\/span>    <span style=\"color: #ff0000\">x:Class<\/span><span style=\"color: #0000ff\">=&quot;HelloWorldApp.MainPage&quot;<\/span>    <span style=\"color: #ff0000\">xmlns<\/span><span style=\"color: #0000ff\">=&quot;http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation&quot;<\/span>    <span style=\"color: #ff0000\">xmlns:x<\/span><span style=\"color: #0000ff\">=&quot;http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml&quot;<\/span>    <span style=\"color: #ff0000\">xmlns:local<\/span><span style=\"color: #0000ff\">=&quot;using:HelloWorldApp&quot;<\/span>    <span style=\"color: #ff0000\">xmlns:d<\/span><span style=\"color: #0000ff\">=&quot;http:\/\/schemas.microsoft.com\/expression\/blend\/2008&quot;<\/span>    <span style=\"color: #ff0000\">xmlns:mc<\/span><span style=\"color: #0000ff\">=&quot;http:\/\/schemas.openxmlformats.org\/markup-compatibility\/2006&quot;<\/span>    <span style=\"color: #ff0000\">mc:Ignorable<\/span><span style=\"color: #0000ff\">=&quot;d&quot;<\/span><span style=\"color: #0000ff\">&gt;<\/span>\r\n\r\n    <span style=\"color: #0000ff\">&lt;<\/span><span style=\"color: #800000\">Grid<\/span> <span style=\"color: #ff0000\">Background<\/span><span style=\"color: #0000ff\">=&quot;{StaticResource ApplicationPageBackgroundThemeBrush}&quot;<\/span><span style=\"color: #0000ff\">&gt;<\/span>        <span style=\"color: #0000ff\">&lt;<\/span><span style=\"color: #800000\">TextBlock<\/span> <span style=\"color: #ff0000\">x:Name<\/span><span style=\"color: #0000ff\">=&quot;TextBlock_Result&quot;<\/span> <span style=\"color: #ff0000\">HorizontalAlignment<\/span><span style=\"color: #0000ff\">=&quot;Left&quot;<\/span> <span style=\"color: #ff0000\">Margin<\/span><span style=\"color: #0000ff\">=&quot;23,70,0,0&quot;<\/span> <span style=\"color: #ff0000\">FontSize<\/span><span style=\"color: #0000ff\">=&quot;23&quot;<\/span> <span style=\"color: #ff0000\">TextWrapping<\/span><span style=\"color: #0000ff\">=&quot;Wrap&quot;<\/span> <span style=\"color: #ff0000\">Text<\/span><span style=\"color: #0000ff\">=&quot;TextBlock&quot;<\/span> <span style=\"color: #ff0000\">VerticalAlignment<\/span><span style=\"color: #0000ff\">=&quot;Top&quot;<\/span> <span style=\"color: #ff0000\">Height<\/span><span style=\"color: #0000ff\">=&quot;282&quot;<\/span> <span style=\"color: #ff0000\">Width<\/span><span style=\"color: #0000ff\">=&quot;612&quot;<\/span><span style=\"color: #0000ff\">\/&gt;<\/span>        <span style=\"color: #0000ff\">&lt;<\/span><span style=\"color: #800000\">Button<\/span> <span style=\"color: #ff0000\">x:Name<\/span><span style=\"color: #0000ff\">=&quot;Button_AccessWebAPI&quot;<\/span> <span style=\"color: #ff0000\">Content<\/span><span style=\"color: #0000ff\">=&quot;Access Web API&quot;<\/span> <span style=\"color: #ff0000\">HorizontalAlignment<\/span><span style=\"color: #0000ff\">=&quot;Left&quot;<\/span> <span style=\"color: #ff0000\">FontSize<\/span><span style=\"color: #0000ff\">=&quot;17&quot;<\/span> <span style=\"color: #ff0000\">Margin<\/span><span style=\"color: #0000ff\">=&quot;23,10,0,0&quot;<\/span> <span style=\"color: #ff0000\">VerticalAlignment<\/span><span style=\"color: #0000ff\">=&quot;Top&quot;<\/span> <span style=\"color: #ff0000\">Click<\/span><span style=\"color: #0000ff\">=&quot;Button_AccessWebAPI_Click&quot;<\/span> <span style=\"color: #0000ff\">\/&gt;<\/span>\r\n\r\n    <span style=\"color: #0000ff\">&lt;\/<\/span><span style=\"color: #800000\">Grid<\/span><span style=\"color: #0000ff\">&gt;<\/span><span style=\"color: #0000ff\">&lt;\/<\/span><span style=\"color: #800000\">Page<\/span><span style=\"color: #0000ff\">&gt;<\/span><\/pre>\n<\/div>\n<p>Pada Button diberikan aksi Click yang akan memanggil method Button_AccessWebAPI_Click yang berisi kode untuk mengakses Web API dan hasilnya akan ditampilkan pada TextBlock.<\/p>\n<p>Dan berikut adalah kode dari file MainPage.xaml.cs.<\/p>\n<p>&#160;<\/p>\n<div id=\"codeSnippetWrapper\" style=\"overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4\">\n<div id=\"codeSnippet\" style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\">\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum1\" style=\"color: #606060\">   1:<\/span> <span style=\"color: #0000ff\">using<\/span> System;<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum2\" style=\"color: #606060\">   2:<\/span> <span style=\"color: #0000ff\">using<\/span> System.Collections.Generic;<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum3\" style=\"color: #606060\">   3:<\/span> <span style=\"color: #0000ff\">using<\/span> System.IO;<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum4\" style=\"color: #606060\">   4:<\/span> <span style=\"color: #0000ff\">using<\/span> System.Linq;<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum5\" style=\"color: #606060\">   5:<\/span> <span style=\"color: #0000ff\">using<\/span> System.Net.Http;<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum6\" style=\"color: #606060\">   6:<\/span> <span style=\"color: #0000ff\">using<\/span> System.Net.Http.Headers;<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum7\" style=\"color: #606060\">   7:<\/span> <span style=\"color: #0000ff\">using<\/span> Windows.Foundation;<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum8\" style=\"color: #606060\">   8:<\/span> <span style=\"color: #0000ff\">using<\/span> Windows.Foundation.Collections;<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum9\" style=\"color: #606060\">   9:<\/span> <span style=\"color: #0000ff\">using<\/span> Windows.UI.Xaml;<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum10\" style=\"color: #606060\">  10:<\/span> <span style=\"color: #0000ff\">using<\/span> Windows.UI.Xaml.Controls;<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum11\" style=\"color: #606060\">  11:<\/span> <span style=\"color: #0000ff\">using<\/span> Windows.UI.Xaml.Controls.Primitives;<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum12\" style=\"color: #606060\">  12:<\/span> <span style=\"color: #0000ff\">using<\/span> Windows.UI.Xaml.Data;<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum13\" style=\"color: #606060\">  13:<\/span> <span style=\"color: #0000ff\">using<\/span> Windows.UI.Xaml.Input;<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum14\" style=\"color: #606060\">  14:<\/span> <span style=\"color: #0000ff\">using<\/span> Windows.UI.Xaml.Media;<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum15\" style=\"color: #606060\">  15:<\/span> <span style=\"color: #0000ff\">using<\/span> Windows.UI.Xaml.Navigation;<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum16\" style=\"color: #606060\">  16:<\/span>&#160; <\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum17\" style=\"color: #606060\">  17:<\/span> <span style=\"color: #008000\">\/\/ The Blank Page item template is documented at http:\/\/go.microsoft.com\/fwlink\/?LinkId=234238<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum18\" style=\"color: #606060\">  18:<\/span>&#160; <\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum19\" style=\"color: #606060\">  19:<\/span> <span style=\"color: #0000ff\">namespace<\/span> HelloWorldApp<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum20\" style=\"color: #606060\">  20:<\/span> {<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum21\" style=\"color: #606060\">  21:<\/span>     <span style=\"color: #008000\">\/\/\/ &lt;summary&gt;<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum22\" style=\"color: #606060\">  22:<\/span>     <span style=\"color: #008000\">\/\/\/ An empty page that can be used on its own or navigated to within a Frame.<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum23\" style=\"color: #606060\">  23:<\/span>     <span style=\"color: #008000\">\/\/\/ &lt;\/summary&gt;<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum24\" style=\"color: #606060\">  24:<\/span>     <span style=\"color: #0000ff\">public<\/span> <span style=\"color: #0000ff\">sealed<\/span> <span style=\"color: #0000ff\">partial<\/span> <span style=\"color: #0000ff\">class<\/span> MainPage : Page<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum25\" style=\"color: #606060\">  25:<\/span>     {<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum26\" style=\"color: #606060\">  26:<\/span>         <span style=\"color: #0000ff\">private<\/span> HttpClient hc;<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum27\" style=\"color: #606060\">  27:<\/span>&#160; <\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum28\" style=\"color: #606060\">  28:<\/span>         <span style=\"color: #0000ff\">public<\/span> MainPage()<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum29\" style=\"color: #606060\">  29:<\/span>         {<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum30\" style=\"color: #606060\">  30:<\/span>             <span style=\"color: #0000ff\">this<\/span>.InitializeComponent();<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum31\" style=\"color: #606060\">  31:<\/span>&#160; <\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum32\" style=\"color: #606060\">  32:<\/span>             hc = <span style=\"color: #0000ff\">new<\/span> HttpClient();<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum33\" style=\"color: #606060\">  33:<\/span>             hc.BaseAddress = <span style=\"color: #0000ff\">new<\/span> Uri(<span style=\"color: #006080\">&quot;http:\/\/localhost:33011\/&quot;<\/span>);<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum34\" style=\"color: #606060\">  34:<\/span>             hc.DefaultRequestHeaders.Accept.Add(<span style=\"color: #0000ff\">new<\/span> MediaTypeWithQualityHeaderValue(<span style=\"color: #006080\">&quot;application\/xml&quot;<\/span>));<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum35\" style=\"color: #606060\">  35:<\/span>&#160; <\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum36\" style=\"color: #606060\">  36:<\/span>         }<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum37\" style=\"color: #606060\">  37:<\/span>&#160; <\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum38\" style=\"color: #606060\">  38:<\/span>         <span style=\"color: #008000\">\/\/\/ &lt;summary&gt;<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum39\" style=\"color: #606060\">  39:<\/span>         <span style=\"color: #008000\">\/\/\/ Invoked when this page is about to be displayed in a Frame.<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum40\" style=\"color: #606060\">  40:<\/span>         <span style=\"color: #008000\">\/\/\/ &lt;\/summary&gt;<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum41\" style=\"color: #606060\">  41:<\/span>         <span style=\"color: #008000\">\/\/\/ &lt;param name=&quot;e&quot;&gt;Event data that describes how this page was reached.  The Parameter<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum42\" style=\"color: #606060\">  42:<\/span>         <span style=\"color: #008000\">\/\/\/ property is typically used to configure the page.&lt;\/param&gt;<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum43\" style=\"color: #606060\">  43:<\/span>         <span style=\"color: #0000ff\">protected<\/span> <span style=\"color: #0000ff\">override<\/span> <span style=\"color: #0000ff\">void<\/span> OnNavigatedTo(NavigationEventArgs e)<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum44\" style=\"color: #606060\">  44:<\/span>         {<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum45\" style=\"color: #606060\">  45:<\/span>         }<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum46\" style=\"color: #606060\">  46:<\/span>&#160; <\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum47\" style=\"color: #606060\">  47:<\/span>         <span style=\"color: #0000ff\">private<\/span> async <span style=\"color: #0000ff\">void<\/span> Button_AccessWebAPI_Click(<span style=\"color: #0000ff\">object<\/span> sender, RoutedEventArgs e)<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum48\" style=\"color: #606060\">  48:<\/span>         {<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum49\" style=\"color: #606060\">  49:<\/span>             var response = await hc.GetAsync(<span style=\"color: #006080\">&quot;api\/HelloWorld\/&quot;<\/span>);<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum50\" style=\"color: #606060\">  50:<\/span>             response.EnsureSuccessStatusCode(); <span style=\"color: #008000\">\/\/ Throw on error code.<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum51\" style=\"color: #606060\">  51:<\/span>&#160; <\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum52\" style=\"color: #606060\">  52:<\/span>             var result = await response.Content.ReadAsStringAsync();<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum53\" style=\"color: #606060\">  53:<\/span>&#160; <\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum54\" style=\"color: #606060\">  54:<\/span>             TextBlock_Result.Text = result;<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum55\" style=\"color: #606060\">  55:<\/span>         }<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum56\" style=\"color: #606060\">  56:<\/span>     }<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\"><span id=\"lnum57\" style=\"color: #606060\">  57:<\/span> }<\/pre>\n<p><!--CRLF--><\/div>\n<\/div>\n<p>Untuk mengunakan class HttpClient pada baris ke-26 maka perlu ditambahkan namespace System.Net.Http seperti yang dilihat pada baris ke-5.&#160; Sedangkan baris ke-34 membutuhkan namespace System.Net.Http.Headers seperti pada baris ke-6.<\/p>\n<p>{<strong><em>Setup Web API Output Format<\/em><\/strong>}<\/p>\n<p>Kita dapat menentukan ingin mendapatkan format output XML atau JSON.&#160; Jika ingin mendapatkan output XML maka cukup gunakan kode seperti pada baris ke-34.&#160; Jika ingin mendapatkan output dengan format JSON maka baris ke-34 tersebut dapat kita ganti seperti berikut :<\/p>\n<div id=\"codeSnippetWrapper\" style=\"overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &#39;Courier New&#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4\">hc.DefaultRequestHeaders.Accept.Add(<span style=\"color: #0000ff\">new<\/span> MediaTypeWithQualityHeaderValue(<span style=\"color: #006080\">&quot;application\/json&quot;<\/span>));<\/pre>\n<\/div>\n<p>Berikut adalah hasil jika format output yang digunakan adalah JSON :<\/p>\n<p><a href=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image26.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image_thumb27.png\" width=\"240\" height=\"100\" \/><\/a><\/p>\n<p>Dan berikut adalah jika format output yang digunakan adalah XML :<\/p>\n<p><a href=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image27.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"http:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image_thumb28.png\" width=\"450\" height=\"107\" \/><\/a><\/p>\n<p>Gampang bukan? Selamat mencoba :)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bagi pengguna Visual Studio 2012, maka akan menemukan ASP.NET MVC 4 pada template project web. Dan yang menarik adalah terdapat Web API sebagai salah satu fitur baru. ASP.NET Web API adalah framework yang memudahkan membuat HTTP Service agar dapat dikonsumsi&hellip;<\/p>\n","protected":false},"author":1,"featured_media":149,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[6],"tags":[23,22,21],"class_list":["post-177","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-softwaredev","tag-vs-2012","tag-windows-8","tag-windows-store-app"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.rezafaisal.net\/wp-content\/uploads\/2012\/10\/image14.png","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1sNAL-2R","_links":{"self":[{"href":"https:\/\/www.rezafaisal.net\/index.php?rest_route=\/wp\/v2\/posts\/177","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rezafaisal.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rezafaisal.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rezafaisal.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rezafaisal.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=177"}],"version-history":[{"count":2,"href":"https:\/\/www.rezafaisal.net\/index.php?rest_route=\/wp\/v2\/posts\/177\/revisions"}],"predecessor-version":[{"id":204,"href":"https:\/\/www.rezafaisal.net\/index.php?rest_route=\/wp\/v2\/posts\/177\/revisions\/204"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rezafaisal.net\/index.php?rest_route=\/wp\/v2\/media\/149"}],"wp:attachment":[{"href":"https:\/\/www.rezafaisal.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rezafaisal.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rezafaisal.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}