本文整理汇总了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();
}
示例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);
}
示例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();
}
示例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);
}
示例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();
}
}