userid from asp.net Membership Authentication?

a 夏天 提交于 2019-12-21 05:35:12

问题


I'm using the asp.net login control for user authentication. I also have the userID in many tables in my application and for now (development purposes), the userID is an int that I'm making up. However, I'd like to start using the userID of the framework in my tables. Where and how do I access the actual userID and what's its datatype?


回答1:


Use the ProviderUserKey member of the MembershipUser object, like this:

MembershipUser user = Membership.GetUser();
string id = user.ProviderUserKey.ToString();



回答2:


In the aspnet_Users Table there is a UserId field with the uniqueidentifier datatype.

You could add the membership table into your own database instead of a separated one.



来源:https://stackoverflow.com/questions/5888877/userid-from-asp-net-membership-authentication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!