locked
Get UserName RRS feed

  • Question

  • User1788249541 posted

    Hi All,

      How to get userName from logging window?

    I want to display some fields depends upon the user Name..

    I used the below code. I got Error.

        string userName = Membership.GetUser().UserName;
    

    Thanks and Regards,

    Friday, September 19, 2014 1:33 AM

Answers

  • User1779161005 posted

    User.Identity.Name will give you the current logged in user's username

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 19, 2014 9:51 AM

All replies

  • User197322208 posted

    . I got Error.

    What error?

    Friday, September 19, 2014 1:40 AM
  • User1788249541 posted

    Thanks for reply...

      This variable declared in globally,  Object Reference error... 

    vjagades

    . I got Error.

    What error?

    Friday, September 19, 2014 1:42 AM
  • User1779161005 posted

    User.Identity.Name will give you the current logged in user's username

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 19, 2014 9:51 AM
  • User197322208 posted

    This variable declared in globally,  Object Reference error... 

    Please reproduce exactly the whole error.

    Friday, September 19, 2014 10:11 AM
  • User-1151753377 posted

    Hi vjagades,

    According to your description, you’d like to get the Username that is verified.

    You could refer to the method below in MSDN:

    String username = Membership.GetUser(User.Identity.Name);

    Or try to this:

    MembershipUser myObject = Membership.GetUser();
    string UserID = myObject.ProviderUserKey.ToString();

     

    If you have any other questions, please don’t hesitate to post this forum.

    Best Regards,

    Summer

    Monday, September 22, 2014 2:50 AM