Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            var currentDirectory = Directory.GetCurrentDirectory();

            var host = new WebHostBuilder()
                .UseIISIntegration()
                .UseKestrel()
                .UseContentRoot(currentDirectory)
                .UseStartup<Startup>()
                .Build();

            using (host)
            {
                using (var cts = new CancellationTokenSource())
                {
                    host.Run((services) =>
                    {
                        var orchardHost = new OrchardHost(
                            services,
                            System.Console.In,
                            System.Console.Out,
                            args);

                        orchardHost
                            .RunAsync()
                            .Wait();

                        cts.Cancel();

                    }, cts.Token, "Application started. Press Ctrl+C to shut down.");
                }
            }
        }
 public static void Main(string[] args)
 {
     var host = new WebHostBuilder()
     .UseStartup<TestStartup>()
     .Build();
     host.Run();
 }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            if (Debugger.IsAttached)
            {
                Environment.SetEnvironmentVariable(
                    "ASPNETCORE_ENVIRONMENT", 
                    EnvironmentName.Development);
            }	    
	    
            var config = new ConfigurationBuilder()
                	  .AddJsonFile("hosting.json", optional: true)
        		  .AddEnvironmentVariables("ASPNETCORE_")
                	  .AddCommandLine(args)
                	  .Build();

            var host = new WebHostBuilder()
                        .UseKestrel()
                        .UseContentRoot(Directory.GetCurrentDirectory())
                        .UseConfiguration(config)
                        .UseIISIntegration()
                        .UseStartup<Startup>()
                        .Build();

            host.Run();
        }
Ejemplo n.º 4
0
Archivo: Startup.cs Proyecto: krwq/cli
        public static int Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("KestrelHelloWorld <url to host>");
                return 1;
            }

            var url = new Uri(args[0]);
            Args = string.Join(" ", args);

            var host = new WebHostBuilder()
                .UseServer("Microsoft.AspNetCore.Server.Kestrel")
                .UseUrls(url.ToString())
                .UseStartup<Startup>()
                .Build();

            ServerCancellationTokenSource = new CancellationTokenSource();

            // shutdown server after 20s.
            var shutdownTask = Task.Run(async () =>
            {
                await Task.Delay(20000);
                ServerCancellationTokenSource.Cancel();
            });

            host.Run(ServerCancellationTokenSource.Token);
            shutdownTask.Wait();

            return 0;
        }
Ejemplo n.º 5
0
        public static void Main(string[] args)
        {
            while (true)
            {
                var host = new WebHostBuilder()
                    .UseKestrel()
                    .UseContentRoot(Directory.GetCurrentDirectory())
                    .UseIISIntegration()
                    .UseStartup<Startup>()
                    .Build();

                var lifetime = (IApplicationLifetime)host.Services.GetService(typeof(IApplicationLifetime));
                Task.Run(() =>
                {

                    while (true)
                    {
                        var line = Console.ReadLine();
                        if (line == "r")
                        {
                            Console.WriteLine("Restarting");
                            lifetime.StopApplication();
                            break;
                        }
                    }
                });

                host.Run();
            }
        }
Ejemplo n.º 6
0
        public static void Main(string[] args)
        {
            var configuration = new ConfigurationBuilder()
                .AddJsonFile(HostingJsonFileName, optional: true, reloadOnChange: true)
                .AddEnvironmentVariables()
                .AddCommandLine(args)
                .Build();

            var host = new WebHostBuilder()
                .UseConfiguration(configuration)
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseKestrel(
                    options =>
                    {
                        // TODO: for Kestrel to serve HTTPS, a certificate is required
                        //options.UseHttps()
                        // Do not add the Server HTTP header when using the Kestrel Web Server.
                        options.AddServerHeader = false;
                    })
                // $Start-WebServer-IIS$
                .UseIISIntegration()
                // $End-WebServer-IIS$
                .UseStartup<Startup>()
                .Build();

            host.Run();
        }
Ejemplo n.º 7
0
        public static void Main(string[] args)
        {
            var config = new ConfigurationBuilder()
                .AddCommandLine(args)
                .AddEnvironmentVariables(prefix: "ASPNETCORE_")
                .AddJsonFile("hosting.json", optional: true)
                .Build();

            var host = new WebHostBuilder()
                .UseConfiguration(config) // Default set of configurations to use, may be subsequently overridden 
              //.UseKestrel()
                .UseContentRoot(Directory.GetCurrentDirectory()) // Override the content root with the current directory
                .UseUrls("http://*:1000", "https://*:902")
                .UseEnvironment("Development")
                .UseWebRoot("public")
                .ConfigureServices(services =>
                {
                    // Configure services that the application can see
                    services.AddSingleton<IMyCustomService, MyCustomService>();
                })
                .Configure(app =>
                {
                    // Write the application inline, this won't call any startup class in the assembly

                    app.Use(next => context =>
                    {
                        return next(context);
                    });
                })
                .Build();

            host.Run();
        }
Ejemplo n.º 8
0
        public static void Main(string[] args)
        {
            var config = new ConfigurationBuilder()
                .AddCommandLine(args)
                .Build();

            var host = new WebHostBuilder()
                .UseKestrel()
                .UseConfiguration(config)
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .Build();

            // Delete UNIX pipe if it exists at startup (eg. previous process crashed before cleaning it up)
            var addressFeature = host.ServerFeatures.Get<IServerAddressesFeature>();
            var url = ServerAddress.FromUrl(addressFeature.Addresses.First());
            if (url.IsUnixPipe && File.Exists(url.UnixPipePath))
            {
                Console.WriteLine("UNIX pipe {0} already existed, deleting it.", url.UnixPipePath);
                File.Delete(url.UnixPipePath);
            }

            host.Run();
        }
Ejemplo n.º 9
0
        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                .UseUrls("http://localhost:8080")
                .UseKestrel()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .Build();

            var restartTime = 0;

            Restart:

            try
            {
                host.Run();
            }
            catch (Exception ex)
            {
                Logger.Error("Unhandled exception occured while host is running.", ex);
                if (restartTime <= MaxRestartTime)
                {
                    restartTime++;

                    Logger.Info("Trying to restart...");

                    goto Restart;
                }
            }

            ClearUp();
        }
Ejemplo n.º 10
0
        public static void Main(string[] args)
        {
            var builder = new WebHostBuilder()
                .UseKestrel()
                .UseStartup<Startup>()
                .Build();

            builder.Run();
        }
Ejemplo n.º 11
0
        // Entry point for the application.
        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
              //.UseKestrel()
                .UseStartup<StartupHelloWorld>()
                .Build();

            host.Run();
        }
Ejemplo n.º 12
0
        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                .UseDefaultConfiguration(args)
                .UseStartup<Startup>()
                .Build();

            host.Run();
        }
Ejemplo n.º 13
0
        public static void Main(string[] args)
        {
            var application = new WebHostBuilder()
                .UseConfiguration(WebHostConfiguration.GetDefault(args))
                .UseStartup<Startup>()
                .Build();

            application.Run();
        }
Ejemplo n.º 14
0
        public static void Main(string[] args)
        {
            var host = new WebHostBuilder().UseKestrel()
                                           .UseContentRoot(Directory.GetCurrentDirectory())
                                           .UseStartup<Startup>()
                                           .Build();

            host.Run();
        }
Ejemplo n.º 15
0
        public static void Main(string[] args)
        {
            var app = new WebHostBuilder()
                .UseServer("Microsoft.AspNetCore.Server.Kestrel")
                .UseUrls("http://*:5004")
                .UseStartup<Startup>()
                .Build();

            app.Run();
        }
        public static void Main(string[] args)
        {
            var host = new Microsoft.AspNetCore.Hosting.WebHostBuilder()
                       .UseKestrel()
                       .UseContentRoot(Directory.GetCurrentDirectory())
                       .UseStartup <Startup>()
                       .Build();

            host.Run();
        }
Ejemplo n.º 17
0
        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                .UseServer("Microsoft.AspNetCore.Server.Kestrel")
                .UseDefaultConfiguration(args)
                .UseStartup<Startup>()
                .Build();

            host.Run();
        }
Ejemplo n.º 18
0
        // Entry point for the application.
        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                .UseKestrel()
                // .UseIIS() // This repo can no longer reference IIS because IISIntegration depends on it.
                .UseStartup<Startup>()
                .Build();

            host.Run();
        }
Ejemplo n.º 19
0
        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                .UseKestrel()
                .UseIISIntegration()
                .UseStartup<Startup>()
                .Build();

            host.Run();
        }
Ejemplo n.º 20
0
        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                .UseKestrel()
                .UseUrls("http://*:5001")
                .UseStartup<Startup>()
                .Build();

            host.Run();
        }
Ejemplo n.º 21
0
        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                .UseIISIntegration()
                .UseStartup("TestSites.Portable")
                .UseKestrel()
                .Build();

            host.Run();
        }
Ejemplo n.º 22
0
 public static void Main(string[] args)
 {
     Console.WriteLine("Hello World!");
     var host = new WebHostBuilder()
                 .UseServer("Microsoft.AspNetCore.Server.Kestrel")
                 .UseContentRoot(Directory.GetCurrentDirectory())
                 .UseDefaultConfiguration(args)
                 .UseStartup<Startup>()
                 .Build();
     host.Run();
 }
Ejemplo n.º 23
0
        public static void Main(string[] args)
        {
            var host = new Microsoft.AspNetCore.Hosting.WebHostBuilder()
                .UseKestrel()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .Build();

            host.Run();
        }
 public static void Main(string[] args)
 {
     global::log4net.Config.XmlConfigurator.Configure(new FileInfo("log4net.config"));
     var host = new WebHostBuilder()
         .UseKestrel()
         .UseContentRoot(Directory.GetCurrentDirectory())
         .UseIISIntegration()
         .UseStartup<Startup>()
         .Build();
     host.Run();
 }
Ejemplo n.º 25
0
 public static void Main(string[] args)
 {
     var host = new WebHostBuilder()
         .UseKestrel()
         .UseUrls("http://0.0.0.0:5000")
         .UseContentRoot(Directory.GetCurrentDirectory())
         .UseIISIntegration()
         .UseStartup<Startup>()
         .Build();
     host.Run();
 }
Ejemplo n.º 26
0
        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                        .UseWebListener()
                        .UseUrls("http://www.binding1.co.nz:80;http://www.binding2.co.nz:80")
                        .UseContentRoot(Directory.GetCurrentDirectory())
                        .UseStartup<Startup>()
                        .Build();

            host.Run();
        }
Ejemplo n.º 27
0
Archivo: Program.cs Proyecto: proog/g_
 public static void Main(string[] args)
 {
     var cwd = Directory.GetCurrentDirectory();
     var host = new WebHostBuilder()
         .UseKestrel()
         .UseContentRoot(cwd)
         .UseWebRoot(Path.Combine(cwd, "public"))
         .UseStartup<Startup>()
         .Build();
     host.Run();
 }
Ejemplo n.º 28
0
        /// <summary>
        /// 程式進入點
        /// </summary>
        /// <param name="args">執行參數</param>
        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()//WebHost建構器
                .UseKestrel()//可使用Kestrel
                .UseContentRoot(Directory.GetCurrentDirectory())//設定根目錄
                .UseIISIntegration()//可使用IIS
                .UseStartup<Startup>()//設定初始化類別
                .Build();//建構WebHost

            host.Run();//開始執行WebHost
        }
Ejemplo n.º 29
0
        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                    .UseKestrel()
                    .UseUrls(new string[] { "http://localhost:7770"})
                    .UseContentRoot(Directory.GetCurrentDirectory())
                    .UseStartup<Startup>()
                    .Build();

            host.Run();
        }
Ejemplo n.º 30
0
        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                        .UseServer("Microsoft.AspNetCore.Server.Kestrel")
                        .UseApplicationBasePath(Directory.GetCurrentDirectory())
                        .UseDefaultConfiguration(args)
                        .UseIISPlatformHandlerUrl()
                        .UseStartup<Startup>()
                        .Build();

            host.Run();
        }
Ejemplo n.º 31
0
        public static void Main(string[] args)
        {
            var server = typeof(KestrelServer).GetTypeInfo().Assembly.FullName;

            var host = new WebHostBuilder()
                .UseKestrel()
                .UseUrls(new[]{ "http://0.0.0.0:8000" })
                .UseStartup<Startup>()
                .Build();

            host.Run();
        }
Ejemplo n.º 32
0
        public static void Main(string[] args)
        {
            var host =
                new Microsoft.AspNetCore.Hosting.WebHostBuilder()
                .UseKestrel()
                .UseContentRoot(System.IO.Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup <Startup>()
                .UseApplicationInsights()
                .Build();

            host.Run();
        }
Ejemplo n.º 33
0
        public static Task Run(String pEndpoint)
        {
            return(Task.Run(() =>
            {
                var host = new Microsoft.AspNetCore.Hosting.WebHostBuilder()
                           .UseKestrel(options =>
                {
                    //options.Limits.MaxRequestBodySize = null;
                    //options.Limits.MaxRequestBufferSize = null;
                })
                           .UseIISIntegration()
                           .UseUrls(pEndpoint)
                           .UseStartup <SignalRStartup>()
                           .Build();

                host.Run();
            }));
        }