Recommended value of DependencyInjectionContextType for web applications

Posts   
 
    
AlbertK
User
Posts: 44
Joined: 23-Dec-2009
# Posted on: 11-Jan-2010 20:44:41   

What is the recommended value of DependencyInjectionContextType attribute for validators and authorizers in ASP.NET web applications - Singleton or NewInstancePerTarget?

Thank you.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 12-Jan-2010 02:00:17   

In almost all cases NewInstancePerTarget (the default) would fit. In such case every target gets a new instance of the instance type injected.

In Singleton, every target gets the same instance of the instance type injected. This will be useful if, for instance, you have an Auditor or Validator that writes directly in a single text file.

If you are using Validators with straight forward validation I think NewInstancePerTarget (the default) is recommended.

David Elizondo | LLBLGen Support Team
AlbertK
User
Posts: 44
Joined: 23-Dec-2009
# Posted on: 12-Jan-2010 17:39:04   

Thanks.