using System; using System.Diagnostics; using System.Web.Http; using System.Web.Http.SelfHost; using MarketData; using MarketData.Utils; using MarketDataServer.Authorization; using MarketDataServer.Handlers; namespace MarketDataServer { // Needs to be run as administrator or use the following netsh http add urlacl url=http://+:8000/ user=[europa]\[skess] // netsh http add urlacl url=http://+:8000/ user=europa\sean class Program { static readonly Uri _baseAddress = new Uri("http://localhost:8000/"); static void Main(string[] args) { MDTrace.LogLevel = LogLevel.DEBUG; String strLogFile = "marketdataserver.log"; Utility.DeleteFile(strLogFile); Trace.Listeners.Add(new TextWriterTraceListener(strLogFile)); Authorizations.GetInstance().IsEnabled = true; // Set up server configuration HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(_baseAddress); config.Routes.MapHttpRoute(name: "DefaultApi", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional }); config.MessageHandlers.Add(new CustomHeaderHandler()); // Create server var server = new HttpSelfHostServer(config); // Start listening server.OpenAsync().Wait(); MDTrace.WriteLine(LogLevel.DEBUG,$"Web API Self hosted on {_baseAddress} Hit ENTER to exit..."); Console.ReadLine(); server.CloseAsync().Wait(); } } }