C#
protected void Page_Load(object sender, EventArgs e)
{
System.Web.Security.MembershipUser mu = System.Web.Security.Membership.GetUser();
string strUsrId = mu.ProviderUserKey.ToString();
}
VB.NET
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim mu As System.Web.Security.MembershipUser = System.Web.Security.Membership.GetUser()
Dim strUsrId As String = mu.ProviderUserKey.ToString()
End Sub
When I run the C# code, it gives an error:
ReplyDeleteObject reference not set to an instance of an object.
Which doesnt make sense..
Its not triggering till after logging in to the site. Any ideas?
i think it should be
ReplyDeleteProtected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim mu As System.Web.Security.MembershipUser = System.Web.Security.Membership.GetUser("user name")
Dim strUsrId As String = mu.ProviderUserKey.ToString()
End Sub
Thanks a lot
ReplyDelete