.Net Core相关

Posted by hqpsoft on November 25, 2016

特性

  • EF查询也支持异步了
  • Kestrel绑定域名
    public static void Main(string[] args)
          {
          var host = new WebHostBuilder()
                          .UseKestrel()
                          .UseUrls("http://www.binding1.co.nz:5100;http://www.binding2.co.nz:5200")
                          .UseContentRoot(Directory.GetCurrentDirectory())
                          .UseIISIntegration()
                          .UseStartup<Startup>()
                          .Build();
              host.Run();
          }
    

记录

依赖注入(DI)

瞬时
瞬时(Transient)生命周期服务在它们每次请求时被创建。这一生命周期适合轻量级的,无状态的服务。

作用域
作用域(Scoped)生命周期服务在每次请求被创建一次。

单例
单例(Singleton)生命周期服务在它们第一次被请求时创建(或者如果你在 ConfigureServices
运行时指定一个实例)并且每个后续请求将使用相同的实例。如果你的应用程序需要单例行为,建议让服务容器管理服务的生命周期而不是在自己的类中实现单例模式和管理对象的生命周期。

Creative Commons License
This work is licensed under a CC A-S 4.0 International License.