In Core 1.0, the Program.cs file looks as under

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;

namespace Example1
public class Program
public static void Main(string[] args)
var host = new WebHostBuilder()


Explain it.

 Posted by Rajnilari2015 on 8/9/2016 | Category: ASP.NET Core Interview questions | Views: 2719 | Points: 40

The Main() method uses WebHostBuilder(). It is use to build up the HTTP pipeline via webHostBuilder.Use() chaining it all together with WebHostBuilder.Build() by using the builder pattern. It is available within the Microsoft.AspNet.Hosting namespace.The purpose of the Build method is to build the required services and a Microsoft.AspNetCore.Hosting.IWebHost which hosts a web application.The web hosting environment uses Kestrel, a cross-platform web server. UseContentRoot specifies the content root directory to be used by the web host.UseIISIntegration configures the port and base path the server should listen on when running behind AspNetCoreModule. The app will also be configured to capture startup errors. WebHostBuilder uses the UseIISIntegration for hosting in IIS and IIS Express. UseStartup specifies the startup type to be used by the web host. The Startup class is the place where we define the request handling pipeline and where any services needed by the app are configured. The Startup class must be public. The Build and Run methods build the IWebHost that will host the app and start it listening for incoming HTTP requests.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response