MembershipContext gives Null Reference Exception

thawzin latt asked on April 7, 2015 09:10

im trying to get all the child nodes from parent node. This is what i have done

    UserInfo ui = MembershipContext.CurrentUserProfile;
    TreeProvider trp = new TreeProvider(ui);
    CMS.DocumentEngine.TreeNode treeNode = trp.SelectSingleDocument(parentDocumentId);

    CMS.DocumentEngine.TreeNodeCollection items = treeNode.Children;

but this give nothing even there are children available. I check the current user info(MembershipContext.CurrentUserProfile.UserName). but it gives null reference. Can u help me through this?

Recent Answers


Dawid Jachnik answered on April 7, 2015 10:15 (last edited on April 7, 2015 10:16)

Hello, Why don't you try MembershipContext.AuthenticatedUser than the MembershipContext.CurrentUserProfile ?

MembershipContext.CurrentUserProfile is available only when the request contains parameters "userid", "username" or "userguid" with valid value of the user.

4 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.