I've recently started using ASP.NET Forms Authentication and Membership.
I created a C# project in Visual Studio, which automatically created pages like "/Account/Login.aspx".
I then followed an example for installing aspnet_*
tables to my SQL Server database, and I've been able to use the <asp:CreateUserWizardStep>
control to create a user.
I've then been able to login as this user, and the logged in username appears when calling <asp:LoginName>
However, when I call the following in my C# code, in a Button Click Event Handler, I always get a Null Reference Exception:
string UserID = Membership.GetUser().ProviderUserKey.ToString();
Shouldn't this return the UserID
from my aspnet_users table?
If <asp:LoginName>
is showing a UserName value, shouldn't I always be able to call Membership.GetUser().ProviderUserKey