We are using Microsofts Unity IOC container in an ASP.Net solution.
In one of the top layers we use the RegisterInstance method. We then get it back lower down with the Resolve method.
While looking at another problem we have seen that ASP.Net has thread agility, that is that a request can jump threads.
So the question is if we register an instance on one thread, and the request jumps thread before we resolve the instance, will we get back the correct instance?
If you resolve your type on same container you’ve registered it in (or its child), you’ll get correct instance.
As far as I know there’s no need to register types in container on every request, that’s usually done somewhere on application start.