why is it said that ASP.NET depends on IIS?

bhavna 106 Reputation points
2021-09-11T10:03:05.123+00:00

what is meant by this line?

Hosted within IIS, ASP.NET apps rely on IIS to instantiate certain objects and call certain methods when a request arrives. (https://learn.microsoft.com/en-us/dotnet/architecture/porting-existing-aspnet-apps/app-startup-differences)
I have read many articles, asked many developers, that how exactly ASP.NET apps rely on IIS and no one has given me a satisfactory answer.

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,270 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,351 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Lex Li (Microsoft) 4,742 Reputation points Microsoft Employee
    2021-09-11T18:02:43.447+00:00

    It is unclear what kind of answers will be satisfactory to you, but ASP.NET is not completely open sourced (some classes are open sourced in .NET Framework Reference Source) and its internals are not well documented.

    I wrote about the history around ASP.NET/IIS on Stack Overflow once, https://stackoverflow.com/a/46878663/11182 So the two evolved together in the past decades and have tight integration ever since.

    The actual integration code is deep down inside aspnet_wp.exe, aspnet_isapi.dll and webengine4.dll, so saying "Hosted within IIS, ASP.NET apps rely on IIS to instantiate certain objects and call certain methods when a request arrives" is probably the only feasible way to summarize.

    The "objects" are in fact instances of,

    Everything around ASP.NET page lifecycle can be answered once you know all the details, but that level of knowledge won't be easily gained unless you debug deep into your web apps and IIS.

    The fortunate part is that everything around ASP.NET Core is open sourced, so once you migrate to that new platform you can dig the source code to easily know what's happening under the hood.

    1 person found this answer helpful.

  2. Bruce Zhang-MSFT 3,736 Reputation points
    2021-09-13T02:57:25.44+00:00

    Hi @bhavna ,

    In asp.net core application, kestrel is more like a micro server to handle request and execute the method.

    There are two hosting models in asp.net core application on IIS. In process and out of process.

    When using out of process hosting model, IIS will forward request to kestrel server and Kestrel handles the incoming HTTP traffic and a Kestrel connector hands of an HttpContext to the ASP.NET Core request middleware pipeline for processing.
    131424-2.jpg

    In the in-process hosting model, what ASP.NET Core Module does is to load the CoreCLR and calls the Program.Main method to bootstrap your app’s logic. It then handles the lifetime of the IIS native request.

    App’s logic takes in the HttpContext produced by IISHttpServer which is responsible for converting the native HTTP request to managed before passing the ASP.NET Core middleware pipeline. The middleware pipeline handles the request and passes it on as an HttpContext instance to your app’s logic. The IISHttpServer passes your app’s response back to IIS which then forwards it back to the client initiating the request.
    131298-3.jpg


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Bruce Zhang