[06] within ASP.NET Core in the process (InProcess) hosting

Within ASP.NET Core process (InProcess) hosting

Author: Liang Tongming - Microsoft Most Valuable Professionals (Microsoft MVP) 
article will be updated with the release, I get concerned about the latest version of 
this article comes from "scratch learning ASP.NET Core and EntityFramework Core" directory 
Better Video Course effects: cross platform development and combat to master ASP.NET Core EntityFramework Core 

Within ASP.NET Core process (InProcess) hosting

In this video we will discuss

  • In the process of ASP.NET Core (InProcess) hosting model
  • What is the Kestrel server

When an application performs ASP.NET Core, will look for the .NET runtime  Main()method, because it is the starting point for this application.

Then, the Main()method is called static class WebHoststatic method CreateDefaultBuilder().
This CreateDefaultBuilder()method performs several tasks, such as:

  • The Kestrel as a Web server and enable IIS integration.
  • Loading configuration from source configurations.
  • Configure logging

After the lesson, we will discuss the various configurations available source asp.net core, load the host and application configuration information content and configuration logging and so on.

In this video, let us understand the CreateDefaultBuilder()methods used to configure and set up Web server functionality. ASP.NET Core applications can be hosted in-process (InProcess) process or outside (OutOfProcess) in. In this video, we will discuss in-process (InProcess) hosting the next video, we will discuss the external process (OutOfProcess) hosting.

In-process (InProcess) hosting

To configure InProcess host, please <AspNetCoreHostingModel>add to the project file the application in which the value of InProcess

<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> 
XML

When we choose to use one of the available project templates, create a new ASP.NET Core project, which is the default for all IIS and IIS Express configurations are hosting (InProcess) as in-process.

In the case of InProcess hosted, CreateDefaultBuilder()method calls UseIIS()the method and hosted applications within IIS worker process ** (w3wp.exe or iisexpress.exe) ***.

  • From a performance standpoint, InProcess hosting provides higher throughput than OutOfProcess hosting request.
  • For IIS, the process of execution of the application name is w3wp, for IIS Express, it is iisexpress
  • To obtain the name of the execution of the application process, please useSystem.Diagnostics.Process.GetCurrentProcess().ProcessName
  • When we run the project from Visual Studio, it defaults to IISExpress.
  • IIS Express is a lightweight self-contained version of IIS, optimized for application development. We will not use it for production. In production we will use IIS.
  • We will bring everyone in a later lesson, deploy ASP.NET Core applications on IIS.

Out of process (out-of-Process) hosting

  • There are two Web server, Web server internal and external Web server.
  • Internal Web server is Kestrel, external Web server can be IIS, Nginx or Apache.
  • Use InProcess hosting only one Web server, load IIS asp.net Core applications. Thus, between the internal and external Web server, the request is not their agents and no loss of performance.

What is the Kestrel

Kestrel is ASP.NET Core cross-platform Web server. All supported platforms and versions of .NET Core supported it. It is included by default as an internal server in ASP.NET Core in. Kestrel edge server itself may be used, i.e. the Internet for Web server, it can handle the incoming HTTP requests from the client directly.

In the Kestrel, a process for hosting the application is dotnet.exe. When we use the .NET Core CLI(command line interface) when Core application running .NET, the application uses Kestrel as a Web server.

.NET Core CLI is a cross-platform tool for developing .NET core applications. Using CLI commands us to do:

  • Create a new project based on the specified templates, profiles or solutions
  • Restore all the dependencies and tools required to .Net Core project package
  • Build the project and all its dependencies
  • Run .net Core project and so on ......

We can use .NET Core CLI to do a lot of things.

Simply under the CLI

Use .NET Core CLI run our Asp.Net Core applications.

  • Start Windows Command Prompt
  • Change directory to the file containing the asp.net Core project folder, and then execute dotnet runthe command
  • C:\ Projects \Source\repos\ StudentManagement \ StudentManagement > dotnet run

After the build and run the project in .NET Core CLI, it will show the URL used to access the application. In my example, the application can be accessed through a browser's addresshttp://localhost:5000 查看内容。

In Kestrel, the process for hosting and executing the application is dotnet.exe.

So when we navigate to http://localhost:5000when we will see the process name dotnet.

Next video: outside ASP.NET Core in the process of hosting model

Article Description

If you think my article quality is good, welcome a reward, you can also subscribe to my video Oh, 
is not authorized are not allowed to reprint this article, 52abp.com retain the copyright 
to thank you for your support for my

Guess you like

Origin www.cnblogs.com/wer-ltm/p/11028222.html