วันจันทร์ที่ 29 มีนาคม พ.ศ. 2553

Use Membership to get UserId

User.Identity have name but where userId

Here how to get that

MembershipUser CurrentUser = Membership.GetUser( User.Identity.Name ); // or use Membership.GetUser();
int userID = int.parce( CurrentUser.ProviderUserKey.ToString() );

by the way this mean when you want userID you must connect database so
check on this article for use other way to keep user

http://www.eggheadcafe.com/tutorials/aspnet/33d4018a-03cf-48aa-9b68-82ba27aa6af9/forms-auth-membership-r.aspx

and some customize provider will help this job done.

http://weblogs.asp.net/scottgu/archive/2006/04/13/442772.aspx

ไม่มีความคิดเห็น: