• 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...
  • C# Programming Examples on Sorting
    Today i am going to tell you some of the Sorting programming questions in C#. Q1- Write a C# program to perform Selection sort. Ans:  Sel...
  • Calling Web API Service in a Cross-Domain Using jQuery AJAX
    In this article, I am going to discuss Calling Web API Service in a Cross-Domain Using jQuery AJAX . Please read our previous article befor...
  • ViewBag in ASP.NET Core MVC
    In this article, I am going to discuss the use of ViewBag in ASP.NET Core MVC application with examples. Please read our previous article ...
  • Recursion And Back Tracking
    In this article, I am going to discuss Recursion And BackTracking in detail. Please read our previous article where we discussed Master Th...
  • 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...
  • Binary to Decimal Conversion in C# with Examples
    In this article, I am going to discuss the Binary to Decimal Conversion in C# with some examples. Please read our previous article where w...

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