I am building a User Management section to a website CMS.
The user has a list of users and then clicks the edit button, the system then stored the UserId in a session and goes to the editUser.aspx page which will show the users details.
To get the users details I need to convert the UserId session to a Guid so i can get user details.
I keep getting error message:
System.InvalidCastException: Specified cast is not valid.
Dim selectedUserId As Guid = CType(Session("strUserId"), Guid)
Dim mu As MembershipUser = Membership.GetUser(selectedUserId)
Does anyone know if this is possible?
Thanks in advance.
Use
Guid.Parse()instead. You are storing a string, so must convert from a string back to a Guid.