Question

Someone who works with MVC4 and the SIMPLEMEMBERSHIP knows how can I get a username by the userId? The user is not logged in and I want to delete it, and to delete I have to use

Membership.DeleteUser(string username)
Was it helpful?

Solution

You could use the GetUserNameFromId method of the SimpleMembershipProvider as such:

SimpleMembershipProvider provider = new SimpleMembershipProvider();
string name = provider.GetUserNameFromId(id);

Ensure you have a reference to WebMatrix.WebData so you can use the SimpleMembershipProvider.

OTHER TIPS

SimpleMembershipProvider provider = (SimpleMembershipProvider)Membership.Provider;

string username= provider.GetUserNameFromId(12345); 

//12345 is the id in SM UserProfile db table
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top