自定义User.Identity添加属性

时间:2011-09-30 14:48:26

标签: asp.net asp.net-mvc-3 authentication iidentity

我自定义RoleProviderMembershipProvider

我想在@User.Identity添加一个属性,就像这样做?

示例:

@User.Identity.About => 。还不存在

我以为我会自定义IIdentity,但不知道从哪里开始。

2 个答案:

答案 0 :(得分:1)

您需要创建自己的类来实现IIdentity和IPrincipal。然后在OnPostAuthenticate的global.asax中分配它们。

答案 1 :(得分:-1)

只需创建一个包装器并覆盖Page.User