ASP.NET Core notes.
IConfiguration Configuration {get; set;}
// Default env variable can be seen from project file
// => right click to properties => debug env variables in VS,
// in or Properties/launchSettings.json
public Startup(IHostingEnvironment env){
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appSettings.json")
.AddEnvironmentVariables();
Configuration = builder.Build();
}
ConfigureServices method is where DI issues are going to be handled.
services.AddSingleton<IGreeter, Greeter>();
services.AddSingleton(Instance); ==> Equals to .AsImplementedInterfaces() of Autofac.
AddTransient ==> News when method or class needs
AddScope ==> Http request scope
Configure method is for configuring the HTTP request pipeline, and middlewares.
app.UseTheMiddleWare
ex: app.UseWelcomePage('/welcome');
Middleware registration order is important.
Middlewares are generally a package (Find them on NuGet)