当前位置: 首页>>代码示例>>C#>>正文


C# WebApplicationBuilder.Run方法代码示例

本文整理汇总了C#中Microsoft.AspNet.Hosting.WebApplicationBuilder.Run方法的典型用法代码示例。如果您正苦于以下问题:C# WebApplicationBuilder.Run方法的具体用法?C# WebApplicationBuilder.Run怎么用?C# WebApplicationBuilder.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.AspNet.Hosting.WebApplicationBuilder的用法示例。


在下文中一共展示了WebApplicationBuilder.Run方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        public static void Main(string[] args)
        {
            if (Environment.GetEnvironmentVariable("ASPNET_ENV") == "Debug")
            {
                // Build an ASP.NET 5 web application that serves as the communication listener.
                var webApp = new WebApplicationBuilder().UseConfiguration(WebApplicationConfiguration.GetDefault())
                                                        .ConfigureLogging(factory =>
                                                        {
                                                            factory.AddConsole();
                                                        })
                                                        .UseStartup<Startup>()
                                                        .Build();

                // Replace the address with the one dynamically allocated by Service Fabric.
                webApp.GetAddresses().Clear();
                webApp.GetAddresses().Add(ListeningAddress);
                webApp.Run();

                Thread.Sleep(Timeout.Infinite);

            }
            else
            {
                using (var fabricRuntime = FabricRuntime.Create())
                {
                    fabricRuntime.RegisterServiceType("MicroserviceTemplateType", typeof(MicroserviceTemplate));

                    Thread.Sleep(Timeout.Infinite);
                }
            }
        }
开发者ID:jjcollinge,项目名称:blanky,代码行数:31,代码来源:Program.cs

示例2: Main

        public static void Main(string[] args)
        {
            var application = new WebApplicationBuilder()
                .UseServer("Microsoft.AspNet.Server.Kestrel") // Set the server manually
                .UseApplicationBasePath(Directory.GetCurrentDirectory()) // Override the application base 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();

            application.Run();
        }
开发者ID:leloulight,项目名称:Hosting,代码行数:26,代码来源:StartupFullControl.cs

示例3: Main

        public static void Main(string[] args)
        {
            var application = new WebApplicationBuilder()
                .UseConfiguration(WebApplicationConfiguration.GetDefault(args))
                .UseStartup<Startup>()
                .Build();

            application.Run();
        }
开发者ID:leloulight,项目名称:Entropy,代码行数:9,代码来源:Startup.cs

示例4: Main

        // Entry point for the application.
        public static void Main(string[] args)
        {
            var app = new WebApplicationBuilder()
                .UseServer("Microsoft.AspNet.Server.Kestrel")
                .UseUrls("http://localhost:3333")
                .UseStartup<Startup>()
                .Build();

            app.Run();
        }
开发者ID:naeemsarfraz,项目名称:aspnet5-workshop,代码行数:11,代码来源:Startup.cs

示例5: Main

        // Entry point for the application.
        public static void Main(string[] args)
        {
            var config = WebApplicationConfiguration.GetDefault(args);

            var application = new WebApplicationBuilder()
                .UseConfiguration(config)
                .UseStartup<StartupHelloWorld>()
                .Build();

            application.Run();
        }
开发者ID:leloulight,项目名称:Hosting,代码行数:12,代码来源:StartupHelloWorld.cs

示例6: Main

        // Entry point for the application.
        public static void Main(string[] args)
        {
            var config = WebApplicationConfiguration.GetDefault(args);

            var application = new WebApplicationBuilder()
                .UseConfiguration(config)
                .UseStartup<StartupConfigureAddresses>()
                .UseUrls("http://localhost:5000", "http://localhost:5001")
                .Build();

            application.Run();
        }
开发者ID:leloulight,项目名称:Hosting,代码行数:13,代码来源:StartupConfigureAddresses.cs

示例7: Main

        public static void Main(string[] args)
        {
            var hostingConfiguration = WebApplicationConfiguration.GetDefault(args);

            var app = new WebApplicationBuilder()
                .UseConfiguration(hostingConfiguration)
                .UseEnvironment(EnvironmentName.Development)
                .UseStartup<Startup>()
                .Build();

            app.Run();
        }
开发者ID:naeemsarfraz,项目名称:aspnet5-workshop,代码行数:12,代码来源:Program.cs

示例8: Main

        public static void Main(string[] args)
        {
            if (Environment.GetEnvironmentVariable("ASPNET_ENV") == "Debug")
            {
                try
                {
                    // Build an ASP.NET 5 web application that serves as the communication listener.
                    var webApp = new WebApplicationBuilder().UseConfiguration(WebApplicationConfiguration.GetDefault())
                                                            .ConfigureLogging(factory =>
                                                            {
                                                                factory.AddConsole();
                                                            })
                                                            .UseStartup<Startup>()
                                                            .Build();

                    webApp.GetAddresses().Clear();
                    webApp.GetAddresses().Add(LocalListeningAddress);
                    Console.WriteLine(LocalListeningAddress);
                    webApp.Run();
                    Thread.Sleep(Timeout.Infinite);

                }
                catch (Exception ex)
                {
                    Console.WriteLine("Crashed: {0}", ex);
                    Console.ReadLine();
                }

            }

            using (var fabricRuntime = FabricRuntime.Create())
            {
                fabricRuntime.RegisterServiceType("ServiceDeployerType", typeof(ServiceDeployer));

                Thread.Sleep(Timeout.Infinite);
            }
        }
开发者ID:jjcollinge,项目名称:blanky,代码行数:37,代码来源:Program.cs


注:本文中的Microsoft.AspNet.Hosting.WebApplicationBuilder.Run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。