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


C# WebHostBuilder.UseUrls方法代码示例

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


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

示例1: Main

        public static void Main(string[] args)
        {
            var configBuilder = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("hosting.json");

            var configuration = configBuilder.Build();

            var hostBuilder = new WebHostBuilder();

            // set urls and environment
            hostBuilder
                .UseUrls(configuration["urls"])
                .UseEnvironment(configuration["environment"]);

            // set other common things
            hostBuilder
                .UseKestrel()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>();

            var host = hostBuilder.Build();

            host.Run();
        }
开发者ID:kosmakoff,项目名称:WebApiWithAuth,代码行数:26,代码来源:Program.cs

示例2: Run

        public virtual Task Run(IPEndPoint http, IPEndPoint https, CancellationToken cancelToken) {
            var urls = BuildUrls(http, https);

            var hostBuilder = new WebHostBuilder();
            //        .UseContentRoot(Directory.GetCurrentDirectory())
            ConfigureBuilder(hostBuilder);
            hostBuilder.UseUrls(urls.ToArray());
            var webHost = hostBuilder.Build();
            return TaskExt.StartLongRunningTask(() => webHost.Run(cancelToken), cancelToken);
        }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:10,代码来源:WebServerStartup.cs

示例3: TestWebAppFixture

        public TestWebAppFixture()
        {
            //WebHostBuilder builder = TestServer.CreateBuilder();
            WebHostBuilder builder = new WebHostBuilder();
            builder.UseStartup<Startup>();
            builder.UseUrls("http://localhost:56789");

            TestServer = new TestServer(builder);

            Client = TestServer.CreateClient();
        }
开发者ID:CreatorDev,项目名称:DeviceServer,代码行数:11,代码来源:TestWebAppFixture.cs

示例4: Run

        public virtual Task Run(IPEndPoint http, IPEndPoint https, CancellationToken cancelToken) {
            var hostBuilder = new WebHostBuilder();
            //        .UseContentRoot(Directory.GetCurrentDirectory())
            ConfigureBuilder(hostBuilder);

            var urls = new List<string>();
            if ((http == null) && (https == null))
                throw new CannotOpenApiPortException("No HTTP or HTTPS ports available");
            if (http != null)
                urls.Add(http.ToHttp());
            if (https != null)
                urls.Add(https.ToHttps());
            hostBuilder.UseUrls(urls.ToArray());
            var webHost = hostBuilder.Build();
            return TaskExt.StartLongRunningTask(() => webHost.Run(cancelToken), cancelToken);
        }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:16,代码来源:Startup.cs

示例5: Main

        public static void Main(string[] args)
        {
            ArgsConfig = new ConfigurationBuilder().AddCommandLine(args).Build();
            var configFile = ArgsConfig["config"];
            if (string.IsNullOrEmpty(configFile))
            {
                Console.WriteLine("No Config File");
            }
            else
            {
                var hostBuilder = new WebHostBuilder()
                .UseKestrel()
                .UseConfiguration(ArgsConfig)
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseStartup<Startup>();

                var appConfig = new ConfigurationBuilder()
                        .SetBasePath(Directory.GetCurrentDirectory())
                        .AddJsonFile(configFile,true,true).Build();
                var urls = appConfig["Data:App:urls"].Split(new char[] { ';', ',', ' ' });
                hostBuilder.UseUrls(urls);
                hostBuilder.Build().Run();
            }
        }
开发者ID:Sharelink,项目名称:BahamutFire,代码行数:24,代码来源:Startup.cs


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