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


C# WebHostBuilder.UseStartup方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:coupalm,项目名称:PnP,代码行数:30,代码来源:Program.cs

示例2: HelloWorldMiddlewareTest

 static HelloWorldMiddlewareTest()
 {
     var builder = new WebHostBuilder();
     builder.UseStartup<HelloWorldMiddleware.Startup>();
     Server = new TestServer(builder);
     Client = Server.CreateClient();
 }
开发者ID:tuespetre,项目名称:mvc-sandbox,代码行数:7,代码来源:HelloWorldMiddlewareTest.cs

示例3: LargeContentMiddlewareTest

 static LargeContentMiddlewareTest()
 {
     var builder = new WebHostBuilder();
     builder.UseStartup<LargeContentMiddleware.Startup>();
     Server = new TestServer(builder);
     Client = Server.CreateClient();
 }
开发者ID:tuespetre,项目名称:mvc-sandbox,代码行数:7,代码来源:LargeContentMiddlewareTest.cs

示例4: HelloWorldMvcTest

 static HelloWorldMvcTest()
 {
     var builder = new WebHostBuilder();
     builder.UseStartup<HelloWorldMvc.Startup>();
     builder.UseProjectOf<HelloWorldMvc.Startup>();
     Server = new TestServer(builder);
     Client = Server.CreateClient();
 }
开发者ID:tuespetre,项目名称:mvc-sandbox,代码行数:8,代码来源:HelloWorldMvcTest.cs

示例5: MediumApiTest

 static MediumApiTest()
 {
     var builder = new WebHostBuilder();
     builder.UseStartup<MediumApi.Startup>();
     builder.UseProjectOf<MediumApi.Startup>();
     Server = new TestServer(builder);
     Client = Server.CreateClient();
 }
开发者ID:tuespetre,项目名称:mvc-sandbox,代码行数:8,代码来源:MediumApiTest.cs

示例6: BigViewsTest

 static BigViewsTest()
 {
     var builder = new WebHostBuilder();
     builder.UseStartup<BigViews.Startup>();
     builder.UseProjectOf<BigViews.Startup>();
     Server = new TestServer(builder);
     Client = Server.CreateClient();
 }
开发者ID:tuespetre,项目名称:mvc-sandbox,代码行数:8,代码来源:BigViewsTest.cs

示例7: LargeStaticViewTest

 static LargeStaticViewTest()
 {
     var builder = new WebHostBuilder();
     builder.UseStartup<LargeStaticView.Startup>();
     builder.UseProjectOf<LargeStaticView.Startup>();
     Server = new TestServer(builder);
     Client = Server.CreateClient();
 }
开发者ID:tuespetre,项目名称:mvc-sandbox,代码行数:8,代码来源:LargeStaticViewTest.cs

示例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();
        }
开发者ID:CreatorDev,项目名称:DeviceServer,代码行数:11,代码来源:TestWebAppFixture.cs

示例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()));
        }
开发者ID:OPCFoundation,项目名称:UA-.NETStandardLibrary,代码行数:27,代码来源:HttpsListener.cs

示例10: CreateServer

 protected TestServer CreateServer()
 {
     WebHostBuilder builder = new WebHostBuilder();
     //builder.UseEnvironment("Development");
     builder.UseStartup<Startup>();
     return new TestServer(builder);
 }
开发者ID:aluitink,项目名称:stockpile,代码行数:7,代码来源:ApiTest.cs


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