Scope of User object

Last post 05-09-2008 4:41 PM by DotNetAdvisor. 3 replies.

Sort Posts:

  • Scope of User object

    05-09-2008, 3:27 PM
    • Loading...
    • Skychan
    • Joined on 05-09-2008, 7:15 PM
    • Posts 2

     Hi

    I want to have access to the User object everywhere in my application. I don't understand why the Session and User object are not available to domain logic classes. Clearly there is always only one session and one user when the running thread is executing application code. The session and user belong to the thread (and should be treated as application global objects). There is no way to access the wrong session or the wrong user. So why are they restricted to only .aspx pages? .ascx pages don't even have access to the User object, but thankfully I have access to the Session there so I just place the User within the Session.

    Can someone please help me get access to the User object from domain logic classes?

    thanks :)

     

    Skychan
     

  • Re: Scope of User object

    05-09-2008, 3:58 PM

    You can access pretty much everything you need through the HttpContext class.  It exposes static properties for the current thread.  If you want to get the username of the current thread access it this way:

    HttpContext.Current.User.Identity.Name 

  • Re: Scope of User object

    05-09-2008, 4:38 PM
    • Loading...
    • Skychan
    • Joined on 05-09-2008, 7:15 PM
    • Posts 2

    Thank you so much! I truly appreciate your help! Big Smile 

  • Re: Scope of User object

    05-09-2008, 4:41 PM

    Hey no problem. Wink

    Also, can you mark this thread answered so I don't keep checking on it?  Thanks. 

Page 1 of 1 (4 items)