Create user

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
 
F

Fred

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top