G
George Durzi
Consider these three projects:
- ProjectWeb (my web application)
- Facade (my class library, does data access, etc.)
- Library (a library of classes I reuse in applications)
ProjectWeb references Facade, and on login adds an instance of a
Facade.UserInfo class (a User class) into the user's Session. The session is
called Session["User"], and I can reference the UserInfo properties by
doing: ((UserInfo)Session["User"]).UserId or
((UserInfo)Session["User"]).UserName, etc.
Both ProjectWeb and Facade reference the Library project, as it contains all
the error logging code. (An implementation of Microsoft's ExceptionManager
application block)
In the Library class, there's an error logging class that needs the current
user's UserId in order to write a record into the error log table. I'd like
to grab this from the UserInfo instance that's in Session. I have access to
HttpContext.Current.Session["User"], but I have to cast the object to
UserInfo in order to access it's properties.
Ideally, I would access the UserId property like this:
HttpContext.Current.((UserInfo)Session["User"]).UserId
However, I can't do that because Library would have to reference Facade
(circular reference) in order for me to have access to the UserInfo class in
my code.
Any suggestions on how to do this, without having to create new Session
variables for the UserId?
Thanks!
- ProjectWeb (my web application)
- Facade (my class library, does data access, etc.)
- Library (a library of classes I reuse in applications)
ProjectWeb references Facade, and on login adds an instance of a
Facade.UserInfo class (a User class) into the user's Session. The session is
called Session["User"], and I can reference the UserInfo properties by
doing: ((UserInfo)Session["User"]).UserId or
((UserInfo)Session["User"]).UserName, etc.
Both ProjectWeb and Facade reference the Library project, as it contains all
the error logging code. (An implementation of Microsoft's ExceptionManager
application block)
In the Library class, there's an error logging class that needs the current
user's UserId in order to write a record into the error log table. I'd like
to grab this from the UserInfo instance that's in Session. I have access to
HttpContext.Current.Session["User"], but I have to cast the object to
UserInfo in order to access it's properties.
Ideally, I would access the UserId property like this:
HttpContext.Current.((UserInfo)Session["User"]).UserId
However, I can't do that because Library would have to reference Facade
(circular reference) in order for me to have access to the UserInfo class in
my code.
Any suggestions on how to do this, without having to create new Session
variables for the UserId?
Thanks!