Hi @Isabella Myers ,
loggedInUserId is part of your application's runtime state, so you need to inject it at runtime after a user request starts.
So the easiest solution is to pass it as a method parameter when requesting the data.
If you want to create an object that requires runtime parameters, you can use a factory.
You can drop the act of implementing that factory by either using the Unity version of Typed Factories or let Unity generate factory delegates for you.
You can check the following documentation for detailed instructions.
Run-Time Configuration
https://learn.microsoft.com/en-us/aspnet/mvc/overview/older-versions/hands-on-labs/aspnet-mvc-4-dependency-injection
Dependency Injection Code Smell: Injecting runtime data into components
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.