why does hosting outside IIS is termed as self hosting?

bhavna 106 Reputation points

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

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


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


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

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

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 59,471 Reputation points

    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:


  2. Lex Li (Microsoft) 5,072 Reputation points Microsoft Employee

    "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.