IHostingEnvironment对象中是一些该应用程序的环境信息,包括程序名称信息,根目录,环境名称 等等基本信息
await context.Response.WriteAsync($"name=\"{env.ApplicationName}\"");
await context.Response.WriteAsync($"name=\"{env.ContentRootFileProvider}\"");
await context.Response.WriteAsync($"name=\"{env.ContentRootPath}\"");
await context.Response.WriteAsync($"name=\"{env.EnvironmentName}\"");
await context.Response.WriteAsync($"name=\"{env.WebRootFileProvider}\"");
IApplicationLifetime对象是用来绑定应用程序的运行时事件的
applicationLifetime.ApplicationStarted.Register(() =>
{
Console.WriteLine("Strated");
});
applicationLifetime.ApplicationStopping.Register(() =>
{
Console.WriteLine("Stoping");
});
applicationLifetime.ApplicationStopped.Register(() =>
{
Console.WriteLine("Strated");
}
未完待续...