public static ConfigureSite ( string baseAddress ) : System.Web.Http.SelfHost.HttpSelfHostConfiguration | ||
baseAddress | string | |
리턴 | System.Web.Http.SelfHost.HttpSelfHostConfiguration |
public void Run(string baseAddress) { var config = HypermediaApiConfiguration.ConfigureSite(baseAddress); var host = new HttpSelfHostServer(config); host.OpenAsync().Wait(); Console.WriteLine("Press enter to shutdown service"); Console.ReadLine(); host.CloseAsync().Wait(); }
protected override void OnStart(string[] args) { try { var baseAddress = (args.Length == 0) ? "http://hypermediaapi.com" : args[0]; Trace.WriteLine(String.Format("Service starting on address: {0}", baseAddress)); var config = HypermediaApiConfiguration.ConfigureSite(baseAddress); _Host = new HttpSelfHostServer(config); _Host.OpenAsync().Wait(); Trace.WriteLine("Service started"); } catch (Exception ex) { Trace.TraceError((ex.InnerException != null ? ex.InnerException.Message : ex.Message)); this.Stop(); } }