获取登录的用户的id [英] Get logged in user's id

查看:269
本文介绍了获取登录的用户的id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能登录用户的用户ID?我使用产生AccountModel的标准体系。我可以用得到的用户名:

How can I get the logged in user's UserId? I'm using the standard system generated AccountModel. I can get the username using:

User.Identity.Name

但我看不到用户ID字段中。我想使用的用户ID作为另一个表的外键。

but I don't see the UserId field. I want to use the UserId as a foreign key for another table.

推荐答案

我认为你正在寻找<一href=\"http://msdn.microsoft.com/en-us/library/system.web.security.membershipuser.provideruserkey.aspx\">ProviderUserKey - 获取来自用户的成员资格数据源的用户标识符

object id = Membership.GetUser().ProviderUserKey

<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.security.membership.getuser.aspx\">Membership.GetUser() - 获取从数据源中的信息并更新上次活动日期/时间戳为当前登录的成员资格用户

这篇关于获取登录的用户的id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆