get user identity in user control

Discussion in 'ASP .Net' started by =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=, Oct 25, 2005.

  1. I've created a simple function to capture the userid when a page is hit. I
    can include this function in the page load using if not ispostback, but i'd
    perfer to place it in the page load event of the user control i have created
    for navigation. However, the user object does not appear to be available. Is
    there a way around this? or am i doing something wrong?

    (additional note: i also tried putting it in the global.asax but get an
    error.)
    --
    thanks (as always)
    some day i''m gona pay this forum back for all the help i''m getting
    kes
     
    =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=, Oct 25, 2005
    #1
    1. Advertising

  2. Parent.Page

    --
    Curt Christianson
    site: http://www.darkfalz.com
    blog: http://blog.darkfalz.com



    "WebBuilder451" wrote:

    > I've created a simple function to capture the userid when a page is hit. I
    > can include this function in the page load using if not ispostback, but i'd
    > perfer to place it in the page load event of the user control i have created
    > for navigation. However, the user object does not appear to be available. Is
    > there a way around this? or am i doing something wrong?
    >
    > (additional note: i also tried putting it in the global.asax but get an
    > error.)
    > --
    > thanks (as always)
    > some day i''m gona pay this forum back for all the help i''m getting
    > kes
     
    =?Utf-8?B?Q3VydF9DIFtNVlBd?=, Oct 25, 2005
    #2
    1. Advertising

  3. Kes,

    Check your include files/references in the regular .aspx page. Whichever
    object you're using to obtain user identity is being referenced by the .aspx
    page, but not by the user control. Also, in case the object is already being
    referenced by the user control (which is likely) try creating it via it's
    full path name.

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche
    "WebBuilder451" <> wrote in message
    news:...
    > I've created a simple function to capture the userid when a page is hit. I
    > can include this function in the page load using if not ispostback, but
    > i'd
    > perfer to place it in the page load event of the user control i have
    > created
    > for navigation. However, the user object does not appear to be available.
    > Is
    > there a way around this? or am i doing something wrong?
    >
    > (additional note: i also tried putting it in the global.asax but get an
    > error.)
    > --
    > thanks (as always)
    > some day i''m gona pay this forum back for all the help i''m getting
    > kes
     
    S. Justin Gengo, Oct 25, 2005
    #3
  4. I guess i was hoping the user control would have access to the user identity
    after it was included on the page. this would save me from calling the
    function (created as component) on each aspx page in the site. So far the
    user is found on each page with out problem even when it does not exist (as
    Null or blank). however, i can't help feeling i'm missing something.

    page pg1.aspx has control uctrl1.ascx (as does all other pages on the site).
    With out directly referencing pg1.aspx can i get the user identity?
    thanks
    kes

    --
    thanks (as always)
    some day i''m gona pay this forum back for all the help i''m getting
    kes


    "S. Justin Gengo" wrote:

    > Kes,
    >
    > Check your include files/references in the regular .aspx page. Whichever
    > object you're using to obtain user identity is being referenced by the .aspx
    > page, but not by the user control. Also, in case the object is already being
    > referenced by the user control (which is likely) try creating it via it's
    > full path name.
    >
    > --
    > Sincerely,
    >
    > S. Justin Gengo, MCP
    > Web Developer / Programmer
    >
    > www.aboutfortunate.com
    >
    > "Out of chaos comes order."
    > Nietzsche
    > "WebBuilder451" <> wrote in message
    > news:...
    > > I've created a simple function to capture the userid when a page is hit. I
    > > can include this function in the page load using if not ispostback, but
    > > i'd
    > > perfer to place it in the page load event of the user control i have
    > > created
    > > for navigation. However, the user object does not appear to be available.
    > > Is
    > > there a way around this? or am i doing something wrong?
    > >
    > > (additional note: i also tried putting it in the global.asax but get an
    > > error.)
    > > --
    > > thanks (as always)
    > > some day i''m gona pay this forum back for all the help i''m getting
    > > kes

    >
    >
    >
     
    =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=, Oct 25, 2005
    #4
  5. =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=

    mkaouri

    Joined:
    Dec 31, 2007
    Messages:
    1
    HttpContext.Current.User.Identity.Name

    Good day :veryprou: ,

    I've done it before inside SqlSiteMapProvider.cs and it works; then I've used it later in one of my .ascx user control and it works too.

    So just add the following to your string control or variable:

    HttpContext.Current.User.Identity.Name

    or

    System.Web.HttpContext.Current.User.Identity.Name

    example: String getusername = HttpContext.Current.User.Identity.Name;
     
    mkaouri, Dec 31, 2007
    #5
  6. =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=

    AlbertM.

    Joined:
    Apr 2, 2008
    Messages:
    3
    Thanks to "mkaouri",

    I've been in forums all day and your simple example worked perfect!
     
    AlbertM., Apr 2, 2008
    #6
    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:
    653
    Giovanni Bassi
    Oct 20, 2003
  2. nalbayo
    Replies:
    2
    Views:
    5,519
    Bruce Barker
    Nov 11, 2005
  3. Frederick D'hont
    Replies:
    0
    Views:
    315
    Frederick D'hont
    Jul 25, 2005
  4. Replies:
    6
    Views:
    458
  5. Jeffrey
    Replies:
    3
    Views:
    136
    Joe Kaplan
    Sep 27, 2007
Loading...

Share This Page