Developer Developer - 3 months ago 16
C# Question

IoC lifetime difference

I am a newbie in C #, and just started to learn IoC in web api.
What is the difference in

Transient
and
PerWebRequest
lifestyles

Sorry for bad English.

Answer
  • Singleton

It's mean "one instance for all". All times when you call Resolve (even implicitly) you got the same object

  • Transient

It's opposite to singletone. You'll get as many object as you call Resolve

  • PerWebRequest

Read how Singleton for one request and transient for other (You'll get as many object as request receive)

for more information read the catle.windsor manual or official asp.net docs