Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kieron McIntyre 96 posts 312 karma points
    7 days ago
    Kieron McIntyre
    0

    NullReferenceException in MemberController.PostSave() when calling Roles.GetRolesForUser()

    I have recently upgraded a site from v6.1.6 to v7.10.4 (in multiple steps) and everything is fine with the exception of the Membership functionality.

    The site has several member types and member groups already has 100+ members. However, now I cannot create a new member. When I do I get a NullReferenceException in the logs:

    2018-05-15 11:23:08,894 [P6340/D9/T8] ERROR Umbraco.Web.Editors.MemberController - Unhandled controller exception occurred
    System.NullReferenceException: Object reference not set to an instance of an object.
        at System.Web.Security.Roles.GetRolesForUser(String username)
        at Umbraco.Web.Editors.MemberController.PostSave(MemberSave contentItem)
    

    Looking at the MemberController code in the CMS source, I can see that GetRolesForUser() on line 302 is expecting a non-null contentItem.PersistedContent.Username property but this is null:

    var currRoles = Roles.GetRolesForUser(contentItem.PersistedContent.Username);
    

    I know that it is the Username property that is null since on a previous line MapPropertyValues() is called which references contentItem.PersistedContent and if this property was null, the exception would be thrown here and be shown in the stack trace.

    Can anyone think why this would be the case?

    Thanks.

  • Ravi Motha 251 posts 404 karma points MVP
    7 days ago
    Ravi Motha
    0

    look t the tables and see if the column that should be auto incremented and creating id .. i suspect you've lost that in the scripting

  • Kieron McIntyre 96 posts 312 karma points
    7 days ago
    Kieron McIntyre
    0

    Thanks for the suggestion Ravi. Which table are you suggesting should be autoincrementing? I can't see anything that should be.

  • Ravi Motha 251 posts 404 karma points MVP
    7 days ago
    Ravi Motha
    0

    That is a good question, i would do a schema check with a sql compare or somesuch.. so you can see all the tables that have changed and look at the specific ones which may be regarding user/member

Please Sign in or register to post replies

Write your reply to:

Draft