Page view counter

Master Page User.Identity.Name problem

Last post 09-18-2006 6:07 PM by ethebaud. 3 replies.

Sort Posts:

  • Master Page User.Identity.Name problem

    09-13-2006, 5:41 PM
    • Loading...
    • ethebaud
    • Joined on 09-13-2006, 5:26 PM
    • Posts 3
    • Points 15

    Hello I've written some code to check information based on the authenticated user. The following code works on an ASPX page load but fails when I move into a Master Page. Specifically, the error is "Compiler Error Message: BC30451: Name 'User' is not declared."  

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

     

    ' Get & split Domain user Information

    Dim strDomainUser As String = User.Identity.Name

    ....

     Any help would be appreciated.

    Thanks,

    Ed

  • Re: Master Page User.Identity.Name problem

    09-13-2006, 9:19 PM
    Answer
    • Loading...
    • lostlander
    • Joined on 05-22-2006, 11:55 AM
    • Posts 607
    • Points 3,041

    Try:

    HttpContext.Current.User.identity.name

    Or

    Page.User.Identity.Name

    Hope it helps!^_^

  • Re: Master Page User.Identity.Name problem

    09-13-2006, 9:33 PM
    Answer
    • Loading...
    • mokeefe
    • Joined on 08-20-2006, 5:15 AM
    • Canberra Australia
    • Posts 2,098
    • Points 10,830
    Or

    Dim strDomainUser As String = Context.User.Identity.Name

    Context object is available in earlier dotnet releases also.

    If Context.User.Identity.IsAuthenticated Then

       Response.Write("Current user:" & Context.User.Identity.Name)

    Else

       Response.Write("Unauthenticated request.")

    End If

     

    Rgds,
    Martin.

    For the benefit of all users please mark any post answers as appropriate.
  • Re: Master Page User.Identity.Name problem

    09-18-2006, 6:07 PM
    • Loading...
    • ethebaud
    • Joined on 09-13-2006, 5:26 PM
    • Posts 3
    • Points 15

    Much thanks. Both suggestions worked.

     Ed

Page 1 of 1 (4 items)