title: Getting Current User Id
body: <p>I am trying to get the currently logged in user's UserId as mentioned in this post <a href="http://msdn.microsoft.com/en-us/library/aa478949.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa478949.aspx</a> as part of the aspnet_Membership table.</p>
  
  <p>Here's where I am looking:</p>
  
  <pre><code>    MembershipUser user = null;
  
      if (User != null &amp;&amp; User.Identity != null &amp;&amp; !string.IsNullOrEmpty(User.Identity.Name))
      {
          user = Membership.GetUser(User.Identity.Name);
      }
  
      if (user != null)
      {
          //int id = user.UserId;
      }
  </code></pre>
  
  <p>MembershipUser does not have a UserId. I am trying to user the UserId as a foreign key for other tables I will create. I can use the UserName, but I figured it may be better to use the UserId.</p>