Transient
In .NET, you use transient services for stateless and lightweight services that don't share resources or maintain any internal state. Transient services are a good choice when you need a new instance of a service for each request.
Here are some examples of when to use transient services:
Utility Services
Transient services are ideal for services that perform simple calculations, generate random numbers, or provide general utility functions.
Navigating to Pages
You can use transient services when you want to pass a different object and state around when navigating to pages.
Transient objects are always different, unlike scoped and singleton objects. Scoped objects are the same for a given request but differ across each new request. Singleton objects are the same for every request.
Last updated