Create user

Discussion in 'ASP .Net' started by shapper, Nov 1, 2008.

  1. shapper

    shapper Guest

    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",
    "", 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", "",
    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
    shapper, Nov 1, 2008
    #1
    1. Advertising

  2. shapper

    Fred Guest

    in news:,
    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",
    > "", 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.

    --
    Fred
    Fred, Nov 3, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sonu
    Replies:
    1
    Views:
    793
  2. JB
    Replies:
    1
    Views:
    438
    Mark Rae [MVP]
    Dec 14, 2007
  3. prady
    Replies:
    2
    Views:
    430
    Phil H
    Dec 29, 2007
  4. Krithika San
    Replies:
    3
    Views:
    326
    Marnen Laibow-Koser
    Nov 14, 2009
  5. Iulian Ilea

    problem: create element in create element

    Iulian Ilea, Dec 14, 2006, in forum: Javascript
    Replies:
    4
    Views:
    176
    Iulian Ilea
    Dec 17, 2006
Loading...

Share This Page