why does hosting outside IIS is termed as self hosting?

bhavna 106 Reputation points
2021-09-03T05:06:47.363+00:00

In general, if a third service provider manages the webserver for me then it is hosted, while if I am by myself managing the webserver then it is self-hosting.

In ASP.NET Core, In both places, I am the one who publishes the code on the server, at the time of IIS it is not called self-hosting? what exactly does "self" means?

For me as a programmer, self-hosting means the application should be able to host itself, which means it must be able to listen to the web requests directly or it must run on its own process. Am I wrong? please someone help me to understand the meaning of "self" in self-hosting.

also, the image Microsoft uses to explain self-host is very confusing to me, as far as I know, IIS uses w3wp.exe to execute the application as
128966-showhim.png

the above image is good, w3wp is the process within that our app executes and IIS is the overall container.

but now, look at this image

128967-showhim1.png

Here the application is the wrapper and Kestral is within the application and the process (dotnet.exe/ application.exe) is the wrapper containing the Kestral, why is it so?

for me, it should be

129041-showhim3.png

why my image is different from Microsoft's image for self-hosting? where am I missing the concept?

Internet Information Services
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,158 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,253 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 55,686 Reputation points
    2021-09-03T15:28:19.683+00:00

    kestrel is small event driven web server library. it communicates to AspNetCore modules via HttpContext. There is also a simple library called IISHttpServer that can be used instead of kestrel to communicate via HttpContext.

    if you run the asp.net application from the command line (or process.start), the startup code calls the kestrel library to be the web server. this is called self-hosted, because the standalone app is a webserver.

    if you use the AspNetCore module to host, it loads the app as a dll, and app startup uses IISHttpServer instead of kestrel as the source of the HttpContext messages.

    so, the app code only knows about HttpContext. You can build you own app, and host asp.net app code, and use any transport you want. An example of this is hosting asp.net in electron, where there is no webserver.

    better explanation:

    https://weblog.west-wind.com/posts/2019/Mar/16/ASPNET-Core-Hosting-on-IIS-with-ASPNET-Core-22


  2. Lex Li (Microsoft) 4,662 Reputation points Microsoft Employee
    2021-09-03T19:53:28.68+00:00

    "Self hosting" was a concept introduced in WCF/ASP.NET Web API/SignalR, where you can host such a web service inside a non-IIS process (such as a console app or a Windows service app). This term was defined with such a small scope and widely used that way, because otherwise your web app is hosted inside IIS worker process or ASP.NET worker process. It is not quite applicable to ASP.NET Core, and people don't use it that much in such context.

    You can feel free to talk about other things as your own "self hosting", but just make sure your audience understand your context, and won't be confused within the conversation.