---
title: "What is Host in ASP.NET Core?"  
description: "What is Host in ASP.NET Core?"  
author: "Ashutosh Patel"  
published: 2023-03-06  
updated: 2023-07-08  
canonical: https://www.mindstick.com/forum/157448/what-is-host-in-asp-dot-net-core  
category: "asp.net core"  
tags: ["asp.net", "asp.net core"]  
reading_time: 2 minutes  

---

# What is Host in ASP.NET Core?

What is [Host](https://yourviews.mindstick.com/view/85456/foreign-direct-investment-fdi-and-its-impacts-on-host-countries) in [ASP.NET Core](https://www.mindstick.com/articles/12946/get-started-with-asp-dot-net-core-mvc-and-visual-studio)?

## Replies

### Reply by Aryan Kumar

In [ASP.NET](https://www.mindstick.com/articles/934/default-folders-available-inside-the-asp-dot-net-application-folder) Core, a host is an object that is responsible for running an ASP.NET Core application. It is responsible for starting the application, handling requests, and shutting down the application when it is finished.

The host is implemented as a class that implements the `IHost` interface. The `IHost` interface has a number of methods that are used to start, handle requests, and shut down the application.

The following is an example of a host class:

C#

```plaintext
using Microsoft.AspNetCore.Hosting;

namespace MyApp
{
    public class MyHost : IHost
    {
        public void Start()
        {
            // Start the application
        }

        public void HandleRequest(HttpContext context)
        {
            // Handle a request
        }

        public void Shutdown()
        {
            // Shut down the application
        }
    }
}
```

To create a host object, you can use the `CreateHostBuilder()` method of the `Microsoft.AspNetCore.Hosting.HostingBuilder` class. The `CreateHostBuilder()` method takes a configuration object as its parameter. The configuration object can be used to configure the application, such as the port number that the application will listen on.

The following is an example of how to create a host object:

C#

```plaintext
using Microsoft.AspNetCore.Hosting;

namespace MyApp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            // Create a configuration object
            var configuration = new ConfigurationBuilder()
                .AddCommandLine(args)
                .Build();

            // Create a host object
            var host = new MyHost();

            // Start the host object
            host.Start();

            // Wait for the host object to shut down
            host.WaitForShutdown();
        }
    }
}
```

Once you have created a host object, you can start it by calling the `Start()` method. The `Start()` method will start the application and listen for requests.

To handle a request, you can call the `HandleRequest()` method of the host object. The `HandleRequest()` method takes a `HttpContext` object as its parameter. The `HttpContext` object contains information about the request, such as the URL, the headers, and the body of the request.

To shut down the host object, you can call the `Shutdown()` method. The `Shutdown()` method will shut down the application and release any resources that it is using.


---

Original Source: https://www.mindstick.com/forum/157448/what-is-host-in-asp-dot-net-core

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
