Startup.cs
[assembly: OwinStartup(typeof(ERPSelfHostServer.Startup))] namespace ERPSelfHostServer { public class Startup { // This code configures Web API. The Startup class is specified as a type // parameter in the WebApp.Start method. public void Configuration(IAppBuilder appBuilder) { // Configure Web API for self-host. HttpConfiguration config = new HttpConfiguration(); config.Formatters.Remove(config.Formatters.XmlFormatter); config.Formatters.Add(new BrowserJsonFormatter()); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional } ); // Any connection or hub wire up and configuration should go here appBuilder.MapSignalR(); appBuilder.UseWebApi(config); } } }
Program.cs
static void Main(string[] args) { // bind to all network interfaces //string baseAddress = "http://*:13602/"; string baseAddress = "http://172.20.63.161:13602"; using (WebApp.Start<Startup>(baseAddress)) { Thread.Sleep(Timeout.Infinite); } }
References
http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api
http://anthonychu.ca/post/web-api-owin-self-host-docker-windows-containers/
http://stackoverflow.com/questions/21634333/hosting-webapi-using-owin-in-a-windows-service
http://stackoverflow.com/questions/20068075/owin-startup-class-missing
http://stackoverflow.com/questions/16642651/self-hosted-owin-and-urlacl