本文整理汇总了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);
}
}
}
示例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();
}
示例3: Main
public static void Main(string[] args)
{
var application = new WebApplicationBuilder()
.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
.UseStartup<Startup>()
.Build();
application.Run();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
}