How can I access UserId in ASP.NET Membership without using Membership.GetUser()?

前端 未结 10 513
孤街浪徒
孤街浪徒 2020-12-08 16:07

How can I access UserId in ASP.NET Membership without using Membership.GetUser(username) in ASP.NET Web Application Project?

Can User

10条回答
  •  被撕碎了的回忆
    2020-12-08 17:06

    You have two options here:

    1) Use username as the primary key for your user data table i.e:

    select * from [dbo.User] where Username = 'andrew.myhre'
    

    2) Add UserID to the profile.

    There are pros and cons to each method. Personally I prefer the first, because it means I don't necessarily need to set up the out-of-the-box profile provider, and I prefer to enforce unique usernames in my systems anyway.

提交回复
热议问题