simplemembership MVC4由userId获取用户名

时间:2013-03-04 00:23:31

标签: c# asp.net-mvc-4 membership simplemembership

使用MVC4和SIMPLEMEMBERSHIP的人知道如何通过userId获取用户名?用户未登录,我想删除它,要删除我必须使用

Membership.DeleteUser(string username)

2 个答案:

答案 0 :(得分:3)

您可以使用GetUserNameFromId的{​​{1}}方法:

SimpleMembershipProvider

确保您引用SimpleMembershipProvider provider = new SimpleMembershipProvider(); string name = provider.GetUserNameFromId(id); ,以便使用WebMatrix.WebData

答案 1 :(得分:1)

SimpleMembershipProvider provider = (SimpleMembershipProvider)Membership.Provider;

string username= provider.GetUserNameFromId(12345); 

//12345 is the id in SM UserProfile db table