obtain current logged in user
<p>I'm using Activedirectory as membership provider. I want to store the current logged in user in a session. </p>

<pre><code> protected void user_login_LoggedIn(object sender, EventArgs e)
 {
   MembershipUser user = Membership.GetUser();
 }
</code></pre>

<p>the code above gives the error below</p>

<hr>

<pre><code>The parameter 'username' must not be empty.
Parameter name: username 

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
</code></pre>

<p>Exception Details: </p>

<pre><code>System.ArgumentException: The parameter 'username' must not be empty.
Parameter name: username
</code></pre>

<p>Source Error: </p>

<pre><code>An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
</code></pre>

<p>Stack Trace: </p>

<pre><code>[ArgumentException: The parameter 'username' must not be empty.
Parameter name: username]
   System.Web.Util.SecUtility.CheckParameter(String&amp; param, Boolean checkForNull, Boolean checkIfEmpty, Boolean checkForCommas, Int32 maxSize, String paramName) +1976411
   System.Web.Security.ActiveDirectoryMembershipProvider.CheckUserName(String&amp; username, Int32 maxSize, String paramName) +30
   System.Web.Security.ActiveDirectoryMembershipProvider.GetUser(String username, Boolean userIsOnline) +86
   System.Web.Security.Membership.GetUser(String username, Boolean userIsOnline) +82
   System.Web.Security.Membership.GetUser() +19
   darts.login.user_login_LoggedIn(Object sender, EventArgs e) in E:\Projects\DARTS\source\darts\darts\login.aspx.cs:24
   System.Web.UI.WebControls.Login.OnLoggedIn(EventArgs e) +111
   System.Web.UI.WebControls.Login.AttemptLogin() +179
   System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +101
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +118
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +166
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
</code></pre>

<hr>

<p>Version Information: Microsoft .NET Framework Version:2.0.50727.4211; ASP</p>
