Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent reusing Scope instances for multiple containers inside WebRequestLifestyle #671

dotnetjunkie opened this Issue Mar 13, 2019 · 0 comments


None yet
1 participant
Copy link

dotnetjunkie commented Mar 13, 2019

The SimpleInjector.Integration.Web.WebRequestLifestyle of the SimpleInjector.Integration.Web integration package creates a single Scope instance per web request, even in the case where multiple Container instances are used during that web request.

Although Scope instances can technically be reused by multiple containers, this is not an obvious approach and does causes the Scope to be decoupled from a specific Container instance. This means that the Scope.Container property will return null in that case, while this is unusual, as the other ScopedLifestyle implementations always relate to a single container instance. It can also cause problems in the future when we decide to make the internal Scope.GetOrSetItem method public, as this accepts a delegate that takes the scope's Container instance as input.

@dotnetjunkie dotnetjunkie added this to the v4.5 milestone Mar 13, 2019

dotnetjunkie added a commit that referenced this issue Mar 13, 2019

WebRequestLifestyle now doesn't reuse Scope for multiple containers a…
…ny longer and creates Scope instances that are linked to a Container instance. Fixes #671
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.