Get the latest AI workflows to boost your productivity and business performance, delivered weekly by expert consultants. Enjoy step-by-step guides, weekly Q&A sessions, and full access to our AI workflow archive.
Summary
In this detailed discussion, kudvenkat demystifies in-process hosting within ASP.NET Core applications, explaining the role of Kestrel server and key configurations involved. The transcript explains how the application is launched and hosted using Kestrel, the process names involved, and discusses the benefits of in-process hosting over out-of-process hosting. It also covers how to utilize the .NET Core CLI to run applications and contrasts in-process hosting with out-of-process hosting, briefly introducing the purpose of each. Overall, it provides a developer-friendly description of in-process hosting specifics and prepares for a deeper dive into out-of-process hosting.
Highlights
ASP.NET Core applications can be hosted in-process or out-of-process. 🏠
In-process hosting uses the IIS worker process (w3wp.exe) while developing uses IIS Express (iisexpress.exe). 🤖
The CreateDefaultBuilder method configures the web host, setting defaults for hosting ASP.NET Core apps. 🎛️
Kestrel serves as a high-performance web server that can be used independently or with other servers like IIS or Nginx. 🏎️
Using the .NET Core CLI allows developers to manage project builds, runs, and configurations on any supported platform. 🛠️
Key Takeaways
In-process hosting boosts performance by hosting ASP.NET Core applications directly inside the IIS worker process. 🚀
The CreateDefaultBuilder method helps configure hosting with sensible defaults including setting up the web server. 🔧
With in-process hosting, there's no performance cost associated with proxying between internal and external servers, unlike out-of-process hosting. 🤓
For in-process hosting, the hosting model in the project file should be set to 'in-process.' 📃
Kestrel can serve as an edge server or a web server in out-of-process hosting on non-Windows platforms. 🌐
.NET Core CLI offers multi-platform command-line controls analogous to using Visual Studio. 🎮
Overview
Ever wondered about the different ways your ASP.NET Core application can be hosted? Look no further! In this engaging session, kudvenkat enlightens us on the finer points of in-process hosting — what it is, how it's configured, and why it might be your go-to for optimized performance.
Think of in-process hosting as your application’s direct ticket to efficient request handling. Boasting significant performance benefits, this method reduces the need for middlemen web servers, getting your applications to work faster and smoother. But what about Kestrel, you ask? Fear not! This built-in web server has you covered.
Get your coding gear ready, as understanding hosting methods become crucial when deciding your deployment strategy. You’ll learn about the .NET Core CLI, a cross-platform command-line tool that equips developers with full control over their application’s lifecycle, making it versatile for ASP.NET Core projects across different environments.
Chapters
00:00 - 00:30: Introduction to In Process Hosting This chapter introduces the concept of in process hosting in ASP.NET Core. It is part of a tutorial series on ASP.NET Core, specifically focusing on the Kestrel server. The chapter discusses how the main method in the program.cs file serves as the entry point for the application and elaborates on what happens when the application is executed regarding the .NET runtime.
00:30 - 01:00: Main Method and CreateDefaultBuilder The chapter discusses the entry point of execution in a program, which resides in the 'main method.' It highlights how the 'main method' invokes a method called 'create web host builder.' This, in turn, calls the 'create default builder' static method in the web host class. The primary focus of the chapter is on the 'create default builder' method, which is responsible for setting up the web host to run applications with pre-configured defaults. The chapter outlines the various tasks involved in configuring the web host using this method.
01:00 - 01:30: Tasks Performed by CreateDefaultBuilder The chapter discusses the method 'create default builder' and its role in setting up a webserver. It explains how this method loads host and application configuration information from various sources and configures logging. Future videos are mentioned to cover these topics in detail, including configuration sources and logging in ASP.NET Core.
01:30 - 02:00: Configuring In Process Hosting In this chapter, the focus is on configuring in-process hosting for ASP.NET Core applications. It explains the distinction between hosting in-process and out-of-process, emphasizing the setting within the ASP.NET Core project file that enables in-process hosting. Specifically, you need to include the 'AspNetCoreHostingModel' element with its value appropriately set in the project file. Moreover, there's a mention of a subsequent video that will cover out-of-process hosting.
02:00 - 02:30: Project Template Default Settings In this chapter, the focus is on the automatic inclusion of the ASP.NET Core hosting model element when creating a project using the empty project template. The hosting model element is set to 'in process' by default. This indicates that the application is using the 'in process' hosting model. The chapter likely covers aspects such as implications of using this hosting model and details about the default builder method in the context of an ASP.NET Core project.
02:30 - 03:00: Performance Advantages of In Process Hosting The chapter discusses the performance advantages of in-process hosting. It highlights that when in-process hosting is used, the application is hosted inside the Internet Information Services (IIS) worker process. For IIS, this process is named 'w3wp.exe' and for IIS Express, it is called 'iisexpress.exe'. The significant advantage of in-process hosting is its ability to deliver considerably higher request throughput compared to out-of-process hosting.
03:00 - 03:30: Displaying Process Name in ASP.NET Core The chapter focuses on modifying a basic ASP.NET Core application that initially displays 'Hello World' to instead show the name of the process running and executing the application. The text references specific code located in the 'startup.cs' file, which controls the message displayed in the browser. The objective is to replace the 'Hello World' message with code that displays the process name.
03:30 - 04:00: Using IIS Express for Development This chapter covers the use of IIS Express for application development. It starts with the setup process and then discusses running applications with IIS Express. The chapter includes detailed instructions on using system diagnostics to handle process execution and finding the process name. The content also emphasizes best practices like code readability by breaking long lines for better visibility. The chapter concludes with a demonstration of executing an application using a shortcut command (Control + F5).
04:00 - 05:00: Introduction to Kestrel Server In this chapter, the process hosting and running an ASP.NET Core application is discussed, primarily focusing on the usage of IIS Express. When running a project from Visual Studio, it uses IIS Express by default. IIS Express is described as a lightweight, self-contained version of Internet Information Services (IIS) optimized specifically for development purposes. The chapter clarifies that IIS Express is not used in other contexts beyond development.
05:00 - 06:00: Using .NET Core CLI The chapter titled 'Using .NET Core CLI' discusses the process of deploying ASP.NET Core applications using IIS. It mentions that in a production environment, IIS is utilized, and had IIS been used instead of IIS Express, the process name would have been w3wp. The chapter also highlights that upcoming videos will further explore deploying ASP.NET Core applications to IIS. Additionally, it explains that IIS Express can be found in the system tray and provides options to manage the running website, such as stopping the site or exiting IIS Express.
06:00 - 06:30: Conclusion and Next Steps The chapter discusses the concept of process hosting, highlighting the involvement of two types of web servers: an internal web server (Kestrel) and an external web server, which can be IAS, Nginx, or Apache depending on the operating system. The chapter concludes by indicating that more detailed discussion on out-of-process hosting will be provided in the next video, encouraging understanding of the basic concept first.
ASP NET Core in process hosting Transcription
00:00 - 00:30 they say spot six of a speed or net core tutorial in this video well discuss in process hosting in a spirited core and along the way we'll also discuss what is Kestrel server this is the same product that we've been working with so far in this video series notice within this program dot C s file we have this main method which is the entry point into this application when this application is executed the dotnet runtime looks for
00:30 - 01:00 this main method and this is where the execution starts notice the main method calls this method create web host builder and that method is right here and this method calls create default builder static method of this web host class now this create default builder method sets up the web host that hosts our application with pre-configured defaults as part of setting of the web host this create default builder method does several tasks and here are some of
01:00 - 01:30 the tasks performed by this create default builder method it sets of the webserver loads the host and application configuration information from various configuration sources and configures logging well discuss the various configuration sources available in a speed or net core loading the host and application configuration information and configuring logging in our upcoming videos in this video let's understand what they create default builder method
01:30 - 02:00 does to configure and set up the web server from a hosting standpoint an asp.net core application can be hosted in process or out of process in this video we'll discus in process hosting and in our next video we'll discus over process hosting to configure in process hosting for your application there is one simple setting in your asp.net core project file include this element s Bennett co-hosting model with a value of
02:00 - 02:30 in process now if you recollect from our previous videos in the series we created this asp.net core project using the empty project template if we take a look at the file notice the project template has automatically included this asp net core hosting model element for us and its value is defaulted to in process that means this application at the moment is using in process hosting model so when they create a default builder method
02:30 - 03:00 sees this setting it's going to call use is method behind the scenes and host the app inside of the IAS worker process the worker process name in case of IAS is w3w P dot exe and in case of IAS express it is is express dot exe from a performance standpoint in process hosting delivers significantly higher request throughput than out of process hosting at the moment when we run this
03:00 - 03:30 application all it does is display hello world now instead of displaying hello world let's display the name of the process that's hosting and executing our application this code can help us do that the hello world message that we see in the browser is coming from this file startup dot Sears and the line that this place that message is right here so instead of displaying hello world let's display the name of the process that's
03:30 - 04:00 hosting and executing our application so system dot Diagnostics dot process dot get current process and on that we use the process name property now let's bring this to the next line so we can see the entire code without having to scroll to the right at this point let's run our application by pressing control f5 there we go
04:00 - 04:30 the name of the process that's hosting and running our asp.net core application is is X press Y is X press well that's because at the moment we are running our project from visual studio by default visual studio uses IAS Express to host and run our application as you might already know is Express is a lightweight self-contained version of IAS optimized especially for developing applications we do not use is
04:30 - 05:00 Express in production in production we use IAS if we have used is instead of is Express then the process name here would have been w3 WP we'll discuss deploying asp.net core applications to IAS in our upcoming videos you can find is Express in the system tray when I right-click on the is Express we can see the website that's running we can stop that site if we want to or exit is Express with out
05:00 - 05:30 of process hosting there are two web servers involved an internal web server and an external web server but let's get out of process hosting in detail in our next video for now just understand with out of process hosting there are two web servers internal and external the internal web server is kestrel and the external web server can be IAS nginx are Apache depending on the operating system you
05:30 - 06:00 have on the other hand with in process hosting there's only one web server that is the IAS that hosts the asp.net core application so the point that I'm trying to make is with in process hosting we do not have the performance penalty of proxying request between internal and external web servers if this is not clear at the moment please do not worry we'll discuss all the process hosting in detail in our next video and at that
06:00 - 06:30 point it should be much clearer now let's understand what is Kestrel Kestrel is a cross-platform web server for asp.net core it is supported on all platforms in versions that dotted course aborts it's included by default as an internal server in asp.net core kestrel can be used by itself as an edge server that is internet facing web server that can directly process incoming HTTP requests from the client the name of the
06:30 - 07:00 process in kestrel that hosts and runs our asp.net core application a.net dot exa at the moment we are running our asp.net code application from visual studio by default Visual Studio uses is Express to host and run our application so the process name is is Express we can also run this asp.net core application from the command line using the.net core CLI CLI stands for
07:00 - 07:30 command line interface dotnet course Eli is a cross-platform tool for developing dotnet cover applications it's supported on all platforms Windows Mac OS and all other platforms where dotnet core is supported to use this tool launch console window notice when I type dotnet - - health I see all the commands we can do everything that we can do with Visual Studio using the.net
07:30 - 08:00 core CLI we can create a new project using the new command we can publish the project using the publish command we can build the project we can run the project there are a variety of things that we can do for now let's run our asp.net core project to be able to run our project using the.net core CLI first let's change the directory to the folder that contains our project our project is present in C Drive in the projects folder we have employee management
08:00 - 08:30 folder that's the solution folder within that we have another folder with the same name and that's our project folder while we are in the project folder execute dotnet ran this bills and runs our asp.net core project using the.net core CLI there we go we have our application up and running and it's listening for incoming HTTP request at this URL HTTP localhost 5000 so let's launch
08:30 - 09:00 another browser tab and navigate to localhost 5000 now here's the important bit to understand when a dotted core application is executed using the.net core CLI kestrel is used as the webserver and remember in castro then name of the process that hosts and runs our application is dotnet dot exe and that process name is displayed right here in our next video well disk is out
09:00 - 09:30 of process hosting at that point will be easy to compare in process hosting with out of process hosting thank you for watching you