title: What is the right way to self-host a Web API?
body: <p>I'm not asking for a best practice advice since there are numerous blog posts and tutorials about the topic all over the internet. </p>
  
  <p>I'm asking out of confusion since Microsoft made a lot of change to the whole self hosting procedure and every tutorial I find take a different, deprecated or unfamiliar approach.</p>
  
  <p>My goal is to set up a self hosted <em>Web API</em> in a legacy Windows Service to control various long running tasks from a non-Windows client, such as an Android application where integrating a <em>WCF</em> / <em>SOAP</em> client can really be a PITA. </p>
  
  <p>I'm aware about the fact that <em>WCF</em> is capable of offering a RESTful service, but since Web API is really suited for such a task, I thought I gave it a shot.</p>
  
  <p>This is how I currently start my API hosted using <em>OWIN</em> (<em>Katana</em>):</p>
  
  <pre><code>public class ApiBootstrap {
  
      var httpConfiguration = new HttpConfiguration();
      // ... configure routes etc.
  
      appBuilder.UseWebApi(httpConfiguration);     // appBuilder = IAppBuilder
      var disposable = WebApp.Start&lt;ApiBootstrapper&gt;(_myBaseUri);
  
  }
  </code></pre>
  
  <p>But most tutorials go on a different approach:</p>
  
  <pre><code>var config = new HttpSelfHostConfiguration("http://localhost:999");
  // ... configure routes etc..
  
  var server = new HttpSelfHostServer(config);
  server.OpenAsync().Wait();
  </code></pre>
  
  <p>Now, I understand the <code>HttpSelfHostServer</code> class is from <code>System.Web.Http.SelfHost</code> and not using <em>OWIN</em>, and both work fine. </p>
  
  <p>But I'm struggling for days to achieve very simple tasks such as securing the connection using <em>SSL</em>, creating authorization etc., just because every tutorial I find on those topics referr to the self hosted method not using <em>OWIN</em>. But AFAIK, <em>OWIN</em> (<em>Katana</em>) is Microsofts prefered approach to achieve self hosting. </p>
  
  <p>As a beginner, I am completely confused and helpless!</p>
  
  <p><em><strong>Edit</strong>: 4 upvotes, 1 fav and 30 views in only 6 minutes but still no answer. Can't really say if I'm doing genious coffee stuff here or if it's just an incredible dumb question.</em></p>