Copied to clipboard

Flag this post as spam?

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


  • webmonger 130 posts 285 karma points
    Feb 10, 2012 @ 17:22
    webmonger
    0

    MemberHelper.GetCurrentMember() Cannot perform runtime binding on a null reference

    Hi

    I'm experiencing an issue with the MemberHelper.GetCurrentMember()

    if (MemberHelper.IsLoggedIn())
    {
    dynamic member = MemberHelper.GetCurrentMember();
    if (member.GetType() == typeof(MyMemberProfile))
    {
    return true;
    }
    return false;
    }

    So the code first checks if the user is logged in and that returns true. Second it gets the member and third it checks if the user is of type MyMemberProfile.

    I'm getting a null reference on member.GetType() but i've already checked that the user is logged in so why is it returning null?

    Any ideas welcome.

    Cheers

    Jon

  • Vladan Ostojic 94 posts 210 karma points
    Feb 11, 2012 @ 07:50
    Vladan Ostojic
    0

    Are you checking this in the same request when user actually got logged in?

    Form authentication requires a cookie that is available only in subsequent requests, after logging in (as only in that case authentication cookie will exist).

  • webmonger 130 posts 285 karma points
    Feb 11, 2012 @ 10:59
    webmonger
    0

    Hi Vladan

    No the request is in a HttpHandler. The process is as follows.

    User logs in and is delivered to a page, they then clicks through some private pages that require (MemberHandler.IsLoggedIn()) then they click a link to a handler that process some stuff and as i've said it checks IsLoggedIn and then does GetCurrentMember() which returns null.

    Cheers

  • Vladan Ostojic 94 posts 210 karma points
    Feb 12, 2012 @ 00:36
    Vladan Ostojic
    0

    Ok, so when you make such a call (GetCurrentMember) on some pages other than HttpHandler is it not null? If that's true, than you probably didn't enable cookies or session on your httphandler.

    uSiteBuilder does not do anything special for this. It just calls umbraco.cms.businesslogic.member.Member.GetCurrentMember() method and converts Umbraco member to strongly typed object. So you can also try to call that function (umbraco.cms.businesslogic.member.Member.GetCurrentMember()) and see if you get something that is not null. If you get null, than this problem is not related with uSiteBuilder.

Please Sign in or register to post replies

Write your reply to:

Draft