CurrentUserId (WebSecurity Ref)

The CurrentUserId property returns an int value of the logged in user’s ID. It takes no arguments.

Example

if (WebSecurity.IsAuthenticated)
{
  WebSecurity.CurrentuserId;
}

Always make sure that the user is logged in before getting the ID; otherwise it will show -1.