public HomeController( TransientCreatedByContainer transient, ScopedCreatedByFactory scoped, SingletonCreatedByContainer createdByContainer, SingletonAddedManually manually, ILogger <HomeController> logger) { //_disposable = new MyDisposable(); _logger = logger; }
/// <summary> /// 1.可以通过FromService获取服务 /// 2.HttpContext.RequestServices 获取服务 /// </summary> /// <param name="singletonCreatedByContainer"></param> /// <returns></returns> public IActionResult Index([FromServices] SingletonCreatedByContainer singletonCreatedByContainer) { //HttpContext.Response.RegisterForDispose(_disposable); return(View()); }