I am trying to understand when to use
AddTransient() and AddScoped()
specially in the web api.
I go through the many article on these topic mostly example is showing the object ids on veiw page. what if i am using the web api.
should i use AddTransient for ICustomerService or ICustomerRepository as AddTransient?
AddScoped() - A new instance of a Scoped service is created once per request within the scope. For example, in a web application it creates 1 instance per each http request but uses the same instance in the other calls within that same web request
Please help me to understand the Scope of request
in above defination i am trying to understand the "
uses the same instance in the other calls within that same web request
does it fit in case of .net core rest api project.
What I have tried:
I Create a api controller and fetch the Hashcode of service object injected in constructor of Api controller.