Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confusion: ASP.NET Core 2 is not managed code, but what is the ASP.Net Core Runtime for?

Regarding Microsoft documentation here in the IIS in the Apppool we can set "Not managed code" for our ASP.NET Core 2 App because the ASP.NET Core 2 app does not need a CLR:

enter image description here

This is confusing to us because there is a download page that provides links to download '.NET Core Runtime 2.0.6': https://www.microsoft.com/net/download/all

When ASP.NET Core 2 is not managed code, why is there a Runtime downloadable?

like image 398
Simon Avatar asked Mar 26 '18 07:03

Simon


2 Answers

Asp.net core on IIS runs as a reverse proxy. What that means is:

  1. Asp.net core runs in a separate process. That process runs separate standalone web server (usually Kestrel), bound to some dynamic port on local loopback interface. So for example, it might listen on "localhost:3434".

  2. IIS is aware of that process (on which port it listens, how to start it), and when request is received by IIS - it proxies that request to the asp.net core local web server running in separate process.

That means there is not need to run CLR in IIS managed pool, because actual asp.net core is NOT run inside IIS application pool process.

Of course asp.net core process itself needs managed runtime, but it can load this runtime itself, without any assistance from IIS.

Update: as stated in comment, next version of ASP.NET 2.1 will introduce in-process model for asp.net core hosted in IIS. In that case, asp.net core code will actually run inside IIS application pool. However, even in that case application pool .NET CLR version should be left as "no managed code", because asp.net core IIS module will load .NET Core CLR itself, without IIS intervention.

like image 181
Evk Avatar answered Sep 28 '22 07:09

Evk


It says so right in the next line of where you got your screenshot from:

ASP.NET Core runs in a separate process and manages the runtime.

ASP.NET Core doesn't rely on loading the desktop CLR.

(emphasis mine)

So it needs a runtime. The page even tells you how to install the runtime in previous steps. It's just that the IIS AppPool does not load the runtime itself, therefor the AppPool does not need to know about the runtime.

like image 36
nvoigt Avatar answered Sep 28 '22 05:09

nvoigt