Unable to get Context.User.Identity.Name

Discussion in 'ASP .Net' started by Arjen, Aug 26, 2005.

  1. Arjen

    Arjen Guest

    Hi,

    I try to get the 'Context.User.Identity.Name' from inside the global.asax in
    the 'Application_BeginRequest' event.

    I get this error message:
    Object reference not set to an instance of an object.

    You can simple test this with:
    Response.Write(Context.User.Identity.Name);

    How can I get there the name?

    Thanks!
    Arjen, Aug 26, 2005
    #1
    1. Advertising

  2. Arjen

    Dave Fancher Guest

    The identity of the user has not been established when
    Application_BeginRequest executes. If you need to access User.Identity,
    you'll need to choose another event later in the request's life cycle.

    I recommend reading the following document from the Patterns & Practices
    site. It should give you a pretty thorough understanding of the life cycle
    for an HTTP Request as it relates to ASP.NET.

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetAP04.asp

    HTH
    ----------------
    Dave Fancher
    http://www.davefancher.com

    "Arjen" <> wrote in message
    news:deo06r$isr$1.ov.home.nl...
    > Hi,
    >
    > I try to get the 'Context.User.Identity.Name' from inside the global.asax
    > in the 'Application_BeginRequest' event.
    >
    > I get this error message:
    > Object reference not set to an instance of an object.
    >
    > You can simple test this with:
    > Response.Write(Context.User.Identity.Name);
    >
    > How can I get there the name?
    >
    > Thanks!
    >
    Dave Fancher, Aug 27, 2005
    #2
    1. Advertising

  3. Arjen

    Arjen Guest

    Hi,

    I know the problem, not the solution. I can't find the correct and first
    event to get the User.Identity.
    Can someone help?

    Thanks!



    "Dave Fancher" <> schreef in bericht
    news:...
    > The identity of the user has not been established when
    > Application_BeginRequest executes. If you need to access User.Identity,
    > you'll need to choose another event later in the request's life cycle.
    >
    > I recommend reading the following document from the Patterns & Practices
    > site. It should give you a pretty thorough understanding of the life
    > cycle for an HTTP Request as it relates to ASP.NET.
    >
    > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetAP04.asp
    >
    > HTH
    > ----------------
    > Dave Fancher
    > http://www.davefancher.com
    >
    > "Arjen" <> wrote in message
    > news:deo06r$isr$1.ov.home.nl...
    >> Hi,
    >>
    >> I try to get the 'Context.User.Identity.Name' from inside the global.asax
    >> in the 'Application_BeginRequest' event.
    >>
    >> I get this error message:
    >> Object reference not set to an instance of an object.
    >>
    >> You can simple test this with:
    >> Response.Write(Context.User.Identity.Name);
    >>
    >> How can I get there the name?
    >>
    >> Thanks!
    >>

    >
    >
    Arjen, Aug 27, 2005
    #3
  4. Arjen

    Arjen Guest

    I think I found it:
    Application_PreRequestHandlerExecute

    Arjen



    "Arjen" <> schreef in bericht
    news:depdfr$2oe$1.ov.home.nl...
    > Hi,
    >
    > I know the problem, not the solution. I can't find the correct and first
    > event to get the User.Identity.
    > Can someone help?
    >
    > Thanks!
    >
    >
    >
    > "Dave Fancher" <> schreef in bericht
    > news:...
    >> The identity of the user has not been established when
    >> Application_BeginRequest executes. If you need to access User.Identity,
    >> you'll need to choose another event later in the request's life cycle.
    >>
    >> I recommend reading the following document from the Patterns & Practices
    >> site. It should give you a pretty thorough understanding of the life
    >> cycle for an HTTP Request as it relates to ASP.NET.
    >>
    >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetAP04.asp
    >>
    >> HTH
    >> ----------------
    >> Dave Fancher
    >> http://www.davefancher.com
    >>
    >> "Arjen" <> wrote in message
    >> news:deo06r$isr$1.ov.home.nl...
    >>> Hi,
    >>>
    >>> I try to get the 'Context.User.Identity.Name' from inside the
    >>> global.asax in the 'Application_BeginRequest' event.
    >>>
    >>> I get this error message:
    >>> Object reference not set to an instance of an object.
    >>>
    >>> You can simple test this with:
    >>> Response.Write(Context.User.Identity.Name);
    >>>
    >>> How can I get there the name?
    >>>
    >>> Thanks!
    >>>

    >>
    >>

    >
    >
    Arjen, Aug 27, 2005
    #4
    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:
    638
    Giovanni Bassi
    Oct 20, 2003
  2. nalbayo
    Replies:
    2
    Views:
    5,491
    Bruce Barker
    Nov 11, 2005
  3. Jennifer Mathews

    Context.User.Identity.Name

    Jennifer Mathews, Apr 1, 2009, in forum: ASP .Net
    Replies:
    2
    Views:
    886
    Alexey Smirnov
    Apr 2, 2009
  4. Frederick D'hont
    Replies:
    0
    Views:
    305
    Frederick D'hont
    Jul 25, 2005
  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,059
    Antonio O''Neal
    Nov 3, 2008
Loading...

Share This Page