You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From @robpex on Monday, September 18, 2017 8:25:29 AM
I believe this is the same question that was brought up in issue #22, but I didn't want to reopen an old issue. In that issue, @cwoolum posted some code they used to work around the issue by resolving things from the AutofacWebRequest lifetime scope, but I had some trouble getting that working in my application. I put some debugging around Autofac resolving components, and I noticed that my WebHookHandler is resolved from the root scope rather than AutofacWebRequest and, according to http://docs.autofac.org/en/latest/lifetime/ ...
It is important to always resolve services from a lifetime scope and not the root container.
As a result, the rest of my dependencies are also resolved from root which isn't desired. This seems like something that should be handled via WebHooks, perhaps in one of the registration extensions? Hacking around to get it working with Autofac seems like more work than just implementing web hooks the traditional way so it's difficult to justify using the project without this fixed.
From @robpex on Tuesday, November 28, 2017 5:06:43 PM
@dougbu it's been a while, but I tried refreshing my memory from #22 (I think that issue has more detail if you haven't checked it out yet). From @HenrikFrystykNielsen comment on that issue,
DI is very much supported. In fact, all of WebHooks extensions (handlers, receivers, and a bunch more) are wired up so that it first look in DI and only if nothing is there does it fall back on it's default behavior.
So, I suspect that somewhere in those WebHooks extensions, where it "first looks in DI", is where it's resolving from the root scope. But I don't remember whether or not I actually stepped through that code myself. I realize that's not the most helpful, so I'll have another look to see if I can reproduce this again... but I might not have the time to do it until the new year.
From @dougbu on Tuesday, December 5, 2017 3:55:21 PM
@robpex if we're understanding this issue correctly, one option may be to use ASP.NET's GetDependencyScope(...) extension method when resolving handlers. But, changing the handler resolution pattern i.e. which IDependencyScope we use would be a breaking change -- unfortunately a subtle break. We don't think that's the right approach but an opt-in switch makes it an interesting feature.
We do not plan to make any changes here. But, I'm leaving it open and marking it as up-for-grabs.
From @robpex on Monday, September 18, 2017 8:25:29 AM
I believe this is the same question that was brought up in issue #22, but I didn't want to reopen an old issue. In that issue, @cwoolum posted some code they used to work around the issue by resolving things from the AutofacWebRequest lifetime scope, but I had some trouble getting that working in my application. I put some debugging around Autofac resolving components, and I noticed that my WebHookHandler is resolved from the root scope rather than AutofacWebRequest and, according to http://docs.autofac.org/en/latest/lifetime/ ...
As a result, the rest of my dependencies are also resolved from root which isn't desired. This seems like something that should be handled via WebHooks, perhaps in one of the registration extensions? Hacking around to get it working with Autofac seems like more work than just implementing web hooks the traditional way so it's difficult to justify using the project without this fixed.
Copied from original issue: aspnet/WebHooks#157
The text was updated successfully, but these errors were encountered: