开发者

How to get userid directly after login in

I'm wonder how i can get the userid just after i validate. Is there another method i can use to login than

FormsAuthentication.RedirectFromLoginPage(userName, true);

Here's what i have.

 if (Membership.ValidateUser(userName,开发者_StackOverflow社区 password))
        {

// i get a null object on the below as i haven't logged in yet

 Guid UserID = new Guid(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString());

// some other logic that requires UserId


        }


If you haven't logged them in yet, why not use the userName variable instead of the User object? You've already verified it is a valid username.

if (Membership.ValidateUser(userName, password))
{
    Guid UserID = new Guid(Membership.GetUser(userName).ProviderUserKey.ToString());
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜