获取当前登录的ID用户在ASP.net [英] Getting the ID of the current logged in user in ASP.net
本文介绍了获取当前登录的ID用户在ASP.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能登录的用户当前的id?
我搜索和得到这个code:
how can i get the id of the current logged in user? I search and got this code :
Membership.GetUser(HttpContext.Current.User.Identity.Name).ProviderUserKey.ToString()
但只获得当前用户的名称,我想要得到的是当前用户的ID,谢谢。
but it only gets the name of the current user, what I want to get is the ID of the current user, thanks.
推荐答案
您遇到合适的code,但你并不需要的toString()
方法。
You are having right code, but you don't need toString()
method.
var currentUser = Membership.GetUser(User.Identity.Name);
string username = currentUser.UserName //** get UserName
Guid userID = currentUser.ProviderUserKey //** get user ID
这篇关于获取当前登录的ID用户在ASP.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文