Saturday, April 28, 2018

How does the default Program.cs vary between version 1 and version 2 of .NET Core?

Pages 32 and 33 of "ASP.NET Core 2 and Angular 5" by Valerio De Sanctis touch on this some and basically what is at bullet four here becomes:

using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
namespace TestMakerFreeWebApp
   public class Program
      public static void Main(string[] args)
      public static IWebHost BuildWebHost(string[] args) =>


A host is an execution context for a .NET Core app and if we are doing something for the web we must implement an IWebHost interface as shown above with WebHost.CreateDefaultBuilder which now stands in place of all of the customization logic that explicitly said "Let's use Kestrel." and the like. The only customization is .UseStartup<Startup>() which suggests "Let's find Startup.cs as the second file to use next." and nothing more. I don't yet know how to explicitly NOT use Kestrel, but then again when is that going to come up? WebHost.CreateDefaultBuilder also finds the content root folder holding appsettings.json which is the new web.config.

No comments:

Post a Comment