Injecting a user id into a service in another .dll at run time

jack jon 0 Reputation points
2023-01-29T15:09:34.5733333+00:00
I am using Unity to do our Dependency Injection

I would like to inject the users id into the constructor

Here is my setup:

        private readonly IImportRespository repo;
        private readonly IUserService userService;

        /// <summary>
        /// Initializes a new instance of the </summary>The repo.
        /// The user service.
        /// The user request user identifier.
        public ImportService(IImportRespository repo, IUserService userService, int userRequestUserId)
        {
            this.repo = repo;
            this.userService = userService;
            UserRequestingId = userRequestUserId;
        }
Here is how I'm registering in my global.asax file:

    public class ImportDIRegistration
    {
        /// <summary>
        /// Imports the di registration types.
        /// </summary>
        /// 
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,932 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Dave Patrick 426.1K Reputation points MVP
    2023-01-29T23:18:34.56+00:00

    Might try asking for help over here.

    https://stackoverflow.com/questions/tagged/unity3d+unity-container

    --please don't forget to upvote and Accept as answer if the reply is helpful--

    0 comments No comments