获得当前用户的GUID? [英] Getting the GUID of the current user?
本文介绍了获得当前用户的GUID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用我从用户检索,当他们提交文章的信息添加用户的GUID。我怎样才能获得GUID?
I want to add a user's GUID in with the information I retrieve from a user when they submit a post. How can I get the GUID?
我使用与ASP.NET MVC应用程序走来默认的身份验证系统。
I am using the default authentication system that comes along with an ASP.NET MVC application.
推荐答案
如果您使用的是ASP.NET成员资格提供程序:
If you are using the ASP.NET Membership provider:
MembershipUser user = Membership.GetUser(User.Identity.Name);
Guid guid = (Guid)user.ProviderUserKey;
或者只是:
Guid guid = (Guid)Membership.GetUser().ProviderUserKey;
这篇关于获得当前用户的GUID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文