【发布时间】:2013-09-10 16:36:48
【问题描述】:
我正在尝试使用新的 Visual Studio 2013 Preview for Web 让当前用户进入 Web 表单项目。我可以使用 Page.User 获取用户名,但试图获取用户 ID 是我卡住的地方。它正在使用他们提出的这种新的身份模型。
这就是我所拥有的:
//Gets the correct username
string uname = User.Identity.Name;
//Returns a null object
Microsoft.AspNet.Identity.IUser user = IdentityConfig.Users.Find(uname);
//What I hope to call to add a user to a role
IdentityConfig.Roles.AddUserToRole("NPO", user.Id);
【问题讨论】:
-
你能显示一些代码吗?
-
对不起,是的。现在有示例代码。
标签: asp.net webforms claims-based-identity visual-studio-2013 asp.net-identity