Re: How to add Page.User.Identity.Name into a class file?

Discussion in 'ASP .Net' started by Gregory A. Beamer, Oct 6, 2009.

  1. "aspfun via DotNetMonster.com" <u53138@uwe> wrote in
    news:9d30479485b28@uwe:

    > I use Page.User.Identity.Name to get user's login ID but it only works
    > in the page.
    > I want to add it into a class file but got an error said:
    > Reference to non-shared member requires an object reference
    > How fix it?


    Mark already answered how to do it. Now I am going to tell you why you
    should not do it and instead add the identity as a variable to the class
    or routine in question.

    When you pull from HttpContext in a library, you end up ensuring the
    library cannot be used by anything other than a web application. This
    may be okay, but realize the coupling becomes a constraint if, for
    example, management wants a WPF application with the same code base.

    You can create a UI only class library to handle the pull from
    HttpContext, with windows specific UI class lib(s) for other apps, but
    it makes things a bit dicier to maintain.

    In the long run, feeding the application from UI is a better option.

    Peace and Grace,

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    Twitter: @gbworld
    Blog: http://gregorybeamer.spaces.live.com

    *******************************************
    | Think outside the box! |
    *******************************************
     
    Gregory A. Beamer, Oct 6, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Giovanni Bassi
    Replies:
    0
    Views:
    673
    Giovanni Bassi
    Oct 20, 2003
  2. nalbayo
    Replies:
    2
    Views:
    5,595
    Bruce Barker
    Nov 11, 2005
  3. Gregory A. Beamer
    Replies:
    1
    Views:
    435
    Gregory A. Beamer
    Oct 8, 2009
  4. Shary
    Replies:
    3
    Views:
    499
    Nicole Calinoiu
    Dec 14, 2004
  5. Antonio O''Neal

    user.identity.name returns old AD user name

    Antonio O''Neal, Oct 31, 2008, in forum: ASP .Net Security
    Replies:
    5
    Views:
    2,290
    Antonio O''Neal
    Nov 3, 2008
Loading...

Share This Page