title: Self hosting Web API
body: <p>My program is for Self hosting a Web API in a Windows Application.
  As I dont have much experience in web servie, I request someone's help to fix the problem.</p>
  
  <p>I could make a console application successfully.
  But when I change it in to Windows application, my IDE goes stuck with Error "The application is in Break Mode".</p>
  
  <p>Console Program;</p>
  
  <pre><code>using System.Web.Http;
  using System.Web.Http.SelfHost;
  </code></pre>
  
  <p>Main Function:</p>
  
  <pre><code>
      var config = new HttpSelfHostConfiguration("http://localhost:8080");
                  config.Routes.MapHttpRoute("API Default", "api/{controller}/{id}", new { id = RouteParameter.Optional });
      using (HttpSelfHostServer server = new HttpSelfHostServer(config))
      {
      server.OpenAsync().Wait();
      Console.WriteLine("Press Enter to quit.");  // Removed in Win Form
      Console.ReadLine(); // Removed in Win Form
      }
  
  </code></pre>
  
  <p>API Controller Class; I need to receive data here from "FromBody" attribute.</p>
  
  <pre><code> public class FieldsController : ApiController
      {
          [HttpPost]
          public void PostAction([FromBody] Field model)
          {
              int patientID;
              string name;
              string age;
              patientID = model.patientID;
              name = model.patientName;
              age = model.patientAge;
          }
      }
  </code></pre>