Asp.net Core-IHostingEnvironment和IApplicationLifetime的使用

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");
       }

 

 

 

未完待续...

Asp.net Core-IHostingEnvironment和IApplicationLifetime的使用

上一篇:Download file from a URL using AutoIt, and run in Robot Framework. (Also can use in other application)


下一篇:【转】.NET(C#)有哪些主流的ORM框架,SqlSugar,Dapper,EF还是...