• Home
  • About
  • Contact
  • ado.net
  • angular
  • c#.net
  • design patterns
  • linq
  • mvc
  • .net core
    • .Net Core MVC
    • Blazor Tutorials
  • sql
  • web api
  • dotnet
    • SOLID Principles
    • Entity Framework
    • C#.NET Programs and Algorithms
  • Others
    • C# Interview Questions
    • SQL Server Questions
    • ASP.NET Questions
    • MVC Questions
    • Web API Questions
    • .Net Core Questions
    • Data Structures and Algorithms

Tuesday, August 18, 2020

Kestrel Web Server in ASP.NET Core

 Admin     August 18, 2020     .Net, .Net Core, Asp.Net, C#     No comments   

In this article, I am going to discuss the Kestrel Web Server in ASP.NET Core Application. Please read our previous article before proceeding to this article where we discussed ASP.NET Core InProcess hosting in detail. In our previous article, we discussed that with the OutOfProcess hosting model, there are 2 web servers i.e. one internal web server and one external web server. The internal web server is called as Kestrel and the external web server can be IIS, Apache or Nginx. As part of this article, we are going to discuss the following two important concepts in detail.
  1. What is a Kestrel Web Server?
  2. How to run a .NET Core application using .NET Core CLI?
What is a Kestrel Web Server?
As we already discussed the ASP.NET Core is a cross-platform framework. It means it supports developed and run applications on different types of operating systems such as Windows, Linux, or Mac.

The Kestrel is the cross-platform web server for the ASP.NET Core application. That means this Server supports all the platforms and versions that the ASP.NET Core supports. By default, it is included as the internal web server in the .NET Core application.

The Kestrel Web Server generally used as an edge server i.e. the internet-facing web server which directly processes the incoming HTTP request from the client. In the case of the Kestrel web server, the process name that is used to host and run the ASP.NET Core application is dotnet.exe.

As of now, we are using visual studio to run the ASP.NET Core application. By default, the visual studio uses IIS Express to host and run the ASP.NET Core application. So the process name is IIS Express that we already discussed in our previous article. We can also run the ASP.NET Core application from the command line using the .NET Core CLI. The CLI stands for Command Line Interface.

How to run .NET Core application using .NET Core CLI?
When we run an ASP.NET Core application using the .NET Core CLI, then the .NET Core runtime uses Kestrel as the webserver. The .NET Core CLI (Command Line Interface) is a cross-platform tool that is used for developing ASP.NET core applications on cross-platform such as windows, macs, or Linux.

Open command prompt and type “dotnet —” and press enter as shown below.
Kestrel Web Server in ASP.NET Core application Command Prompt

Once you type the “dotnet —” and click on the enter button then you will find lots of commands as shown below.
.NET Core CLI Commands

Using the CLI (above commands)
  1. You can create a new project using the new command, you can also build the project using the build command, or you can publish the project using the publish command.
  2. It is possible to restore the dependencies and tools which are required for a .net core project using the CLI
Running .NET Core application using .NET Core CLI
We can do a variety of things using the .NET Core CLI. So let’s see how to run a .NET Core application using CLI. To do so please follow the below steps

First, open the Windows Command Prompt. To do so, open the run window and then type cmd and click on the enter button which will open the command prompt

Then you need to change the directory to the folder which contains your asp.net core application. My project is present in “C:\Users\Pranaya\source\repos\FirstCoreWebApplication\FirstCoreWebApplication” folder so I type as shown below to change the directory.
Changing Directory in Command Prompt

Once you change the directory then execute the “dotnet run” command as shown in the below image.
Run the ASP.NET Core application using .NET Core CLI

Once you click on the enter button, then the .NET Core CLI builds and runs the application. It also shows the URL and you can use this URL to access the application. Here, in my case, the application is available at http://localhost:5000

Now open the browser and navigate to the http://localhost:5000 URL and It should display the worker process name as dotnet as shown below.
Kestrel web server worker process name

So this proves that, in the case of the Kestrel web server, the process that is used to host and run the application is dotnet.exe.

In the next article, we will discuss the OutOfProcess hosting in the ASP.NET Core application. Here, in this article, I try to explain the Kestrel Web Server in ASP.NET Core application in detail. I hope this article will help you to understand the Kestrel Web Server in ASP.NET Core Application.

Summary:
I hope this post will be helpful to understand the concept of Kestrel Web Server in ASP.NET Core
Please share this post with your friends and colleagues.
For any queries please post a comment below.
Happy Coding 😉
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Newer Post Older Post

0 comments:

Post a Comment

If you like this website, please share with your friends on Facebook, Twitter, LinkedIn.

Join us on Telegram

Loved Our Blog Posts? Subscribe To Get Updates Directly To Your Inbox

Like us on Facebook

Popular Posts

  • What is Dependency Injection(DI)
    Hi friends! Today we are going to learn about Dependency Injection and in our last session we have come across Static classes and where it s...
  • ASP.NET State Management
    State management is a technique or way to maintain / store the state of an Asp.Net controls, web page information, object/data, and user in ...
  • HTTP Client Message Handler in Web API
    In this article, I am going to discuss HTTP Client Message Handler in Web API with real-time examples. As we already discussed in HTTP Mes...
  • ASP.NET Web API Basic Authentication
    In this article, I am going to discuss how to implement the ASP.NET Web API Basic Authentication step by step with an example. Please read...
  • Navigation Menus in ASP.NET Core
    In this article, I am going to discuss how to create Responsive Navigation Menus in ASP.NET Core Application using bootstrap and JQuery. P...
  • What is Abstract Class and When we should use Abstract Class
    Hi friends! In our previous sessions we have seen  Difference Between Class and Struct . And in our last session  we learnt Usability of Sec...
  • ViewModel in ASP.NET Core MVC
    In this article, I am going to discuss ViewModel in ASP.NET Core MVC application with an example. Please read our previous article before ...

Blog Archive

Contact Form

Name

Email *

Message *

Tags

.Net .Net Core .Net Core MVC Algorithm Angular Anonymous Types Asp.Net Asp.Net MVC Blazor C# Data Structure Database Design Patterns Entity Framework Entity Framework Core Filters Interview Question Management Studio Programming Programs SQL Server SSMS Web API

Copyright © C# Techtics | All Right Reserved.

Protected by Copyscape