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
Hi,
We are using LightInject and ASP .Net Core 2.1 and are using the PerLogicalCallContextScopeManagerProvider.
Recently we found that our PerRequestLifeTime scope was invoking multiple calls to our instance during the same HTTP request.
We changed the scope to the PerScopeLifetime and found the same code only invoked once per HTTP request.
So from a functional point of view this seems to be the correct solution, however we could not find any documentation on how the link is made between the HTTPRequest and the PerScopeLifetime.
In our code we are NOT explicitly calling the Container.BeginScope() however from all our testing we cannot disprove the threading model.
Can you confirm there are no thread/security issues that could cause the same object to be returned from a different HTTP request in this scenario that does not explicitly call the Container.BeginScope()?
The text was updated successfully, but these errors were encountered:
The PerRequestLifeTime returns a new instance per request. Not HttpRequest , but every time an instance is requested from the container. The name PerRequestLifeTime might not be the best name as it can cause confusion when used in web applications. So the PerScopeLifetime is the right lifetime here. The scope in a web application is started when the web request starts and ends when the web request ends. This is done automatically by the Asp.Net infrastructure.
Thanks for the quick reply and clarification of the usage of PerScopeLifetime.
Might be a good idea to mention something like this in the doco as we found it difficult to determine when the Scope is created in ASP .Net and also that we dont have to explicitly call BeginScope when running in ASP .Net.
Again many thanks and happy to close this one
Hi,
We are using LightInject and ASP .Net Core 2.1 and are using the PerLogicalCallContextScopeManagerProvider.
Recently we found that our PerRequestLifeTime scope was invoking multiple calls to our instance during the same HTTP request.
We changed the scope to the PerScopeLifetime and found the same code only invoked once per HTTP request.
So from a functional point of view this seems to be the correct solution, however we could not find any documentation on how the link is made between the HTTPRequest and the PerScopeLifetime.
In our code we are NOT explicitly calling the Container.BeginScope() however from all our testing we cannot disprove the threading model.
Can you confirm there are no thread/security issues that could cause the same object to be returned from a different HTTP request in this scenario that does not explicitly call the Container.BeginScope()?
The text was updated successfully, but these errors were encountered: