问题描述
我正在尝试实现自定义成员资格提供程序,并想更改GetUser方法.问题是GetUser返回MembershipUser,而我想返回MyMembershipUser,它具有两个附加属性FirstName和LastName.我可以在我的成员资格提供程序中创建一个新方法,该方法返回MyMembershipUser,但是我认为这没有任何意义.
I am trying to implement a custom membership provider and want to change the GetUser method. The problem is that GetUser returns MembershipUser and I want to return MyMembershipUser which has two additional properties FirstName and LastName. I can create a new method in my membership provider which returns MyMembershipUser but then I think it won't make any sense.
我将如何去做?
推荐答案
这将违背Membership
类的目的.如果您需要访问其他属性,请执行以下操作:
That would defeat the purpose of the Membership
classes. Do something like this if you need to access other properties:
var user = Membership.GetUser(userName, true) as MyMembershipUser;
真的,您应该有一个单独的Profile
类,该类处理MembershipUser
不提供的内容.
Really you should have a separate Profile
class that handles things that MembershipUser
does not provide.
var profile = Profile.GetProfile(Membership.GetUser(userName, true));
这篇关于实施自定义成员资格提供程序成员资格用户问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!