Outer ASP.NET Core process (out-of-process) hosted

Outer ASP.NET Core process (out-of-process) hosted

In this section, we will discuss in ASP.NET Core Out Of Process Hosting.

Within ASP.NET Core process (InProcess) hosting

We briefly review under ASP.NET Core, we should configure the InProcess server,

We need to add `` <AspNetCoreHostingModel> in the project file 元素,其值为InProcess`

< AspNetCoreHostingModel > InProcess </ AspNetCoreHostingModel >

Use InProcess hosting, application hosting in IIS worker process (w3wp.exe or iisexpress.exe) in. Use InProcess hosting only one Web server, which is carrying our IIS server application.

7 illustrates the process of hosting

Outer ASP.NET Core process (out-of-process) hosted

There are two ways to configure external hosting process:

  • Method One: to < AspNetCoreHostingModel >add an element to the project file for the application, it isOutOfProcess
< AspNetCoreHostingModel > OutOfProcess </ AspNetCoreHostingModel >
  • Method Two: The default is OutOfProcesshosting. Therefore, if we remove from the project file < AspNetCoreHostingModel >elements, the default ASP.NET Core will use the case of OutOfProcesshosting.

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. In the last lesson we discussed what Kestrel

Depending on how you run the asp.net Core applications may or may not use an external Web server.

 

Kestrel is a cross-platform embedded in asp. Net Core application web server. Use 进程外(out-of-Process)托管, Kestrel can be used in two ways:

Kestrel can be used for Internet web server, processing incoming HTTP requests directly. In this model, we do not use an external web server. Only the Kestrel, as the server can customize the Internet for direct processing incoming HTTP requests. When we use. Net Core CLI run asp. When the net Core application, Kestrel is the only process for handling incoming HTTP requests and web server.

kestrel face the Internet

Kestrel may also be used in conjunction with reverse proxy server (e.g., IIS, Nginx or Apache).

With the direction of the agency

To a discussion

If the Kestrel can be used as a Web server alone, why do we need a reverse proxy server?

Because the Kestrel to use "out of process (out-of-process) hosting" and with the reverse proxy server is a good choice, because it provides an additional layer of configuration and security. It might be better to integrate with existing infrastructure. It can also be used for load balancing.

Thus, in the case where a reverse proxy server, it will receive incoming HTTP request from the network, and forwards it to the server for processing Kestrel. When processing the request, the server sends a response to the Kestrel reverse proxy server and reverse proxy server via the network eventually sends a response to the requesting client.

In the back of the lesson, we will learn how to deploy ASP.NET Core applications to use IIS and IIS as a reverse proxy server. When we run directly in Visual Studio application from asp.net Core, IIS Express to use it by default. Since we already have an application configured to use 进程外托管, so under the current circumstances, IIS Express has been acting as a reverse proxy server.

IIS ExpressReceiving incoming HTTP request and forwards it to Kestrelbe processed. KestrelTo process the request and sends the response IIS Express. IIS Express in turn sends the response to the browser.

Use 进程外托管whether or not you use a reverse proxy server, Kestrel servers are processed simultaneously as a server hosting the application request, which is the most we start talking about self-hosting. If reverse proxy server receives incoming HTTP request and forwards it to the server Kestrel. Similarly, it gets a response and sends it to the client from the server Kestrel. Therefore, the process of hosting the application name dotnet.exe.

Use the following code to get the process name

We operate a wave for everyone to take a look at the demo. Remember this line of code, is a knowledge

System.Diagnostics.Process.GetCurrentProcess().ProcessName;

When we use .NET Core CLI run asp.net Core project, by default it will ignore us specified in the .csproj file 托管设置. Therefore, the value of the project file under the `` AspNetCoreHostingModel` label is neglected. Regardless of the value (InProcess or OutOfProcess) you specify how, it is always OutOfProcess hosting, managed application are by Kestrel, at the same time deal with the http request.

A common problem

We can run asp.net Core applications without using the built-in Kestrel Web server do?

The answer is yes you can, you have to believe .NET Core development team. If we use InProcess hosting, the application will be hosted on IIS worker process (w3wp.exe or iisexpress.exe) in. Knowledge Kestrel不与InProcess(进程内)托管一起使用points: .

So .net core how good you know it. Welcome Message interactive - Proxy: refers to IIS, Nginx or Apache, and so on.
 

Welcome to add a personal Micro Signal: Like if thoughts.

I welcome the attention of the public numbers, not only recommend the latest blog for you, there are more surprises waiting for you and resources! Learn together and common progress!


 

 

Guess you like

Origin www.cnblogs.com/cool2feel/p/11446830.html