Steve Wash
Steve Wash

Reputation: 986

aspnet _membership MembershipUser.ProviderUserKey is returning an integer

I'm using the aspnet_membership with an MVC4 website project. This is just for a quick demo, it doesn't need to be robust yet. I haven't defined roles yet, so simply registering should provide access to the various pages.

I need to get the UserId from the User table and I'm using the recommended method Membership.GetUser(User.Identity.Name).ProviderUserKey. However, ProviderUserKey appears to have a value of '2' which is not castable to a Guid. I'm guessing that I haven't set up something in the aspnet_membership that I need to be able to do this. What do I need to do or configure to get a Guid value?

Thanks

Upvotes: 0

Views: 852

Answers (1)

Erik Funkenbusch
Erik Funkenbusch

Reputation: 93444

ASP.NET MVC4 uses SimpleMembership rather than the old SqlMembership. SimpleMembership, by default uses an integer identity key for the users table. If you want a Guid, then you would need to change the way SimpleMembership works or you could go back to using the old SqlMembership.

Upvotes: 2

Related Questions