In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "the use of asp.net core host". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the usage of asp.net core mainframe.
Asp.net core is mainly a web application used to process http requests. The web host (WebHostBuilder) for hosting web applications is used, and for other types of hosts (such as messages, background tasks, and other non-HTTP workloads), use a generic host (HostBuilder). The host that creates the IWebHostBuilder instance in the Main method of the Program class in the program entry usually starts creating the host by calling the CreateDefaultBuilder method of the WebHost static class.
Public class Program {public static void Main (string [] args) {CreateWebHostBuilder (args). Build (). Run ();} public static IWebHostBuilder CreateWebHostBuilder (string [] args) = > WebHost.CreateDefaultBuilder (args) .UseStartup ();}
CreateDefaultBuilder performs the following tasks:
Use the application's managed configuration provider to configure the Kestrel server as a Web server.
Set the content root to the path returned by Directory.GetCurrentDirectory.
Load configuration (host configuration and system configuration)
Add output Log tool
Start IIS integration
You can also instantiate a web host and customize some configuration information according to the needs of the project:
Public static IWebHost CreateWebHostBuilder (string [] args) {var builder = new WebHostBuilder (); return builder .UseKestrel ((builderContext, options) = > {options.Configure (builderContext.Configuration.GetSection ("Kestrel") }) .UseContentRoot (Directory.GetCurrentDirectory ()) .ConfigureAppConfiguration ((hostingContext, config) = > {var env = hostingContext.HostingEnvironment Config.SetBasePath (Directory.GetCurrentDirectory ()) .AddJsonFile (Path.Combine ("Configs", "appsettings.json"), optional: false, reloadOnChange: true) .AddJsonFile (Path.Combine ("Configs", $"appsettings. {env.EnvironmentName} .json") .AddenvironmentVariables () }) .ConfigureLogging ((hostingContext, logging) = > {logging.AddConfiguration (hostingContext.Configuration.GetSection ("Logging")); logging.ClearProviders (); / / logging.AddDatabase () }) .UseIIS () .UseIISIntegration () .UseStartup () .build ();}
Mainly refer to the official document: https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/host/web-host?view=aspnetcore-2.2#manage-the-host
At this point, I believe you have a deeper understanding of "the use of asp.net core host". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.