本文整理汇总了C#中Microsoft.AspNetCore.Hosting.WebHostBuilder.UseStartup方法的典型用法代码示例。如果您正苦于以下问题:C# WebHostBuilder.UseStartup方法的具体用法?C# WebHostBuilder.UseStartup怎么用?C# WebHostBuilder.UseStartup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.AspNetCore.Hosting.WebHostBuilder
的用法示例。
在下文中一共展示了WebHostBuilder.UseStartup方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(string[] args)
{
try
{
var host = new WebHostBuilder()
.UseKestrel(options =>
{
options.UseHttps(@"..\..\certificates\localhost_ssl.pfx", "[email protected]");
options.NoDelay = true;
//I use this to get rid of SSL errors, feel free to remove it.
IConnectionFilter prevFilter = options.ConnectionFilter ?? new NoOpConnectionFilter();
options.ConnectionFilter = new IgnoreSslErrorsConnectionFilter(prevFilter);
}
)
.UseUrls("https://localhost:5000")
.UseContentRoot(Directory.GetCurrentDirectory());
host.UseStartup<Startup>();
var webHost = host.Build();
webHost.Run();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Console.ReadKey();
}
}
示例2: HelloWorldMiddlewareTest
static HelloWorldMiddlewareTest()
{
var builder = new WebHostBuilder();
builder.UseStartup<HelloWorldMiddleware.Startup>();
Server = new TestServer(builder);
Client = Server.CreateClient();
}
示例3: LargeContentMiddlewareTest
static LargeContentMiddlewareTest()
{
var builder = new WebHostBuilder();
builder.UseStartup<LargeContentMiddleware.Startup>();
Server = new TestServer(builder);
Client = Server.CreateClient();
}
示例4: HelloWorldMvcTest
static HelloWorldMvcTest()
{
var builder = new WebHostBuilder();
builder.UseStartup<HelloWorldMvc.Startup>();
builder.UseProjectOf<HelloWorldMvc.Startup>();
Server = new TestServer(builder);
Client = Server.CreateClient();
}
示例5: MediumApiTest
static MediumApiTest()
{
var builder = new WebHostBuilder();
builder.UseStartup<MediumApi.Startup>();
builder.UseProjectOf<MediumApi.Startup>();
Server = new TestServer(builder);
Client = Server.CreateClient();
}
示例6: BigViewsTest
static BigViewsTest()
{
var builder = new WebHostBuilder();
builder.UseStartup<BigViews.Startup>();
builder.UseProjectOf<BigViews.Startup>();
Server = new TestServer(builder);
Client = Server.CreateClient();
}
示例7: LargeStaticViewTest
static LargeStaticViewTest()
{
var builder = new WebHostBuilder();
builder.UseStartup<LargeStaticView.Startup>();
builder.UseProjectOf<LargeStaticView.Startup>();
Server = new TestServer(builder);
Client = Server.CreateClient();
}
示例8: 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();
}
示例9: Start
/// <summary>
/// Starts listening at the specified port.
/// </summary>
public void Start()
{
Startup.Listener = this;
m_host = new WebHostBuilder();
HttpsConnectionFilterOptions httpsOptions = new HttpsConnectionFilterOptions();
httpsOptions.CheckCertificateRevocation = false;
httpsOptions.ClientCertificateMode = ClientCertificateMode.NoCertificate;
httpsOptions.ServerCertificate = m_serverCert;
httpsOptions.SslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12;
m_host.UseKestrel(options =>
{
options.NoDelay = true;
options.UseHttps(httpsOptions);
});
m_host.UseContentRoot(Directory.GetCurrentDirectory());
m_host.UseStartup<Startup>();
m_host.Build();
m_host.Start(Utils.ReplaceLocalhost(m_uri.ToString()));
}
示例10: CreateServer
protected TestServer CreateServer()
{
WebHostBuilder builder = new WebHostBuilder();
//builder.UseEnvironment("Development");
builder.UseStartup<Startup>();
return new TestServer(builder);
}