I am working on asp.net core and I came across concepts like AddTransient, AddSingleton, and AddScoped. They differ in what is the lifecycle of an object.
1.Singleton which creates a single instance throughout the application. It creates the instance for the first time and reuses the same object in all calls.
- Scoped lifetime services are created once per request within the scope. It is equivalent to a singleton in the current scope. For example, in MVC it creates one instance for each HTTP request, but it uses the same instance in the other calls within the same web request.
- Transient lifetime services are created each time they are requested. This lifetime works best for lightweight, stateless services.
I would like to know what is the meaning of a single HTTP request? If I redirect to another page does that mean it's another HTTP request? P.S I have used the above definitions from AddTransient, AddScoped and AddSingleton Services Differences