Working with the Startup class
Another autogenerated element, which exists in all types of ASP.NET Core 2.0 projects, is the Startup
class. As you have seen previously, the Program
class mainly handles everything around the hosting environment. The Startup
class is all about the preloading and configuration of your services and middlewares. Those two classes are the foundations of all ASP.NET Core 2.0 applications.
Let's look at the basic structure of the Startup
class to get a better understanding of what is provided and how to make best use of its functionalities:
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; namespace TicTacToe { public class Startup { public void ConfigureServices(IServiceCollection services) { } public void Configure(IApplicationBuilder app, IHostingEnvironment env) ...