Create user

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I have created a class that inherits MembershipUser:
public class UserHelper : MembershipUser {
....

Then I am creating a user as follows:
UserHelper user = (UserHelper)Membership.CreateUser("me", "pass",
"(e-mail address removed)", null, null, true, null, out status);

Membership.CreateUser returns a MembershipUser

But I get an error:
Unable to cast object of type 'System.Web.Security.MembershipUser' to
type 'MyApp.Security.Membership.UserHelper'.

If I don't cast it, which means, using:
UserHelper user = Membership.CreateUser("me", "pass", "(e-mail address removed)",
null, null, true, null, out status);

It does not compile and I get the error:
Cannot implicitly convert type 'System.Web.Security.MembershipUser' to
'MyApp.Security.Membership.UserHelper'. An explicit conversion exists
(are you missing a cast?)

What am I doing wrong?

Thanks,
Miguel
 
in shapper wrote :
Hello,
Hello,

I have created a class that inherits MembershipUser:
public class UserHelper : MembershipUser {
...

Then I am creating a user as follows:
UserHelper user = (UserHelper)Membership.CreateUser("me", "pass",
"(e-mail address removed)", null, null, true, null, out status);

Membership.CreateUser returns a MembershipUser


If you want CreateUser to return a UserHelper, I think you should also
inherits MemberShipProvider.
 
Back
Top