Reputation: 65411
I am reviewing a project that has used Microsoft Patterns and Practices Unity Container.
There is a single container with 40 registered types, an instance of the container is created for every web service call.
I am wondering:
The web services are hosted in IIS.
Upvotes: 4
Views: 3632
Reputation: 30411
Unity caches all sorts of stuff under the hood the first time a resolve is done. This significantly improves performance on later resolve calls. If you create a new container on every request, you're throwing out those caches.
Keep the container around between requests.
Upvotes: 12
Reputation: 6082
Please create the container and register all types during Application_Start. We've done this for around 200 + types in a large project (wcf and asp.net mvc) and have had no issues.
Thanks
Upvotes: 8