I need to be able to easily grab a username for a lot of queries we're running in an assembly outside the MVC project. I would just add a parameter for all the calls, but there are literally hundreds of them.
My colleague has advised me to pass a static reference to the HttpContext (presumably in OnApplicationStarted or something like that) and get the username from there.
HttpContext always has information pertaining to the current user's session. My concern with this is that if my object (that exists in a separate assembly) is not going to know which user exactly to pull the information from, and that while this may work for a single user, it will pull the wrong username as more users start accessing the system.
Is this a viable way of identifying the username?
How does HttpContext know which user is the current user? Is that mechanism severed outside the project?