【发布时间】:2011-11-28 13:16:09
【问题描述】:
我自定义 RoleProvider 和 MembershipProvider 类
我想在我的@User.Identity 中再添加一个属性,这样做吗?
示例:
@User.Identity.About => .关于尚不存在
我以为我会自定义IIdentity,但不知道从哪里开始。
【问题讨论】:
标签: asp.net asp.net-mvc-3 authentication iidentity
我自定义 RoleProvider 和 MembershipProvider 类
我想在我的@User.Identity 中再添加一个属性,这样做吗?
示例:
@User.Identity.About => .关于尚不存在
我以为我会自定义IIdentity,但不知道从哪里开始。
【问题讨论】:
标签: asp.net asp.net-mvc-3 authentication iidentity
只需创建一个包装器并覆盖Page.User。
【讨论】:
您需要创建自己的类来实现 IIdentity 和 IPrincipal。然后在 OnPostAuthenticate 的 global.asax 中分配它们。
【讨论】:
Application_PostAuthenticate(object sender, EventArgs e) 或 Application_AuthenticateRequest(object sender, EventArgs e) 有什么区别??