0

Hi i need to fetch the id of the live user and i am able to do it.but the problem arises when i switch from one Port to another it does not fetch the user on another port

I have done this:

public static Nullable<int> GetLiveUser()
    {
        if (HttpContext.Current.Session[ConstantHelper.LoginAccountID] != null)
        {
            return ((int)HttpContext.Current.Session[ConstantHelper.LoginAccountID]);
        }
        else
        {
            return null;
        }

    }

ConstantHelper is a class with LoginAccountID as a property.
Please help me

user1274646
  • 921
  • 6
  • 21
  • 46

2 Answers2

2

HttpContext.Current.User.Identity.Name or inside a Controller, User.Identity.Name.

See IIdentity.

jrummell
  • 42,637
  • 17
  • 112
  • 171
0

If you're using razor, simply use @User.Identity.Name in your view. You might also need to disable anonymous authentication and enable Windows Authentication.

armnov
  • 641
  • 1
  • 7
  • 16