Example #1
0
        public static void Main(string[] args)
        {
            if (Constants.DiagnosticsDebugger)
            {
                System.Diagnostics.Debugger.Launch();
            }
            var    exePath           = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
            string pathToContentRoot = Path.GetDirectoryName(exePath);

            if (!Constants.IsService)
            {
                pathToContentRoot = Directory.GetCurrentDirectory();
            }
            var host = new WebHostBuilder()
                       .UseKestrel()
                       .UseContentRoot(pathToContentRoot)
                       .UseIISIntegration()
                       .UseStartup <Startup>()
                       .UseApplicationInsights()
                       .UseUrls("http://+:" + Constants.ServerPort.ToString())
                       .Build();

            if (Constants.IsService)
            {
                host.RunAsCustomService();
            }
            else
            {
                host.Run();
            }
        }
Example #2
0
        public static void Main(string[] args)
        {
            bool isService = true;

            if (Debugger.IsAttached || args.Contains("--console"))
            {
                isService = false;
            }

            var pathToContentRoot = Directory.GetCurrentDirectory();

            if (isService)
            {
                var pathToExe = Process.GetCurrentProcess().MainModule.FileName;
                pathToContentRoot = Path.GetDirectoryName(pathToExe);
            }
            var host = new WebHostBuilder()
                       .UseKestrel()
                       .UseContentRoot(pathToContentRoot)
                       .UseUrls("http://*:5000")
                       .UseStartup <Startup>()
                       .Build();

            if (isService)
            {
                host.RunAsCustomService();
            }
            else
            {
                host.Run();
            }
        }
        public static void Main(string[] args)
        {
            if (Debugger.IsAttached || args.Contains("--debug"))
            {
                var host = new WebHostBuilder()
                           .UseKestrel()
                           .UseContentRoot(Directory.GetCurrentDirectory())
                           .UseIISIntegration()
                           .UseStartup <Startup>()
                           .Build();

                host.Run();
            }
            else
            {
                var exePath       = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
                var directoryPath = Path.GetDirectoryName(exePath);
                var host          = new WebHostBuilder()
                                    .UseKestrel()
                                    .UseContentRoot(directoryPath)
                                    .UseStartup <Startup>()
                                    .UseUrls("http://+:5050")
                                    .Build();
                //http://stackoverflow.com/a/37464074/857956 we could use either of following methods
                //host.RunAsService();
                host.RunAsCustomService();
            }
        }