Copied to clipboard

Flag this post as spam?

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


  • Dan 1288 posts 3921 karma points c-trib
    Jan 10, 2014 @ 17:19
    Dan
    0

    isloggedon is true but getcurrentmember is null - how?

    Hi,

    I have a bug whereby working dev code now throws YSODs on the staging site where it thinks that the member is logged on but the member object is null. This is probably best explained in code:

    if (umbraco.library.IsLoggedOn())
    {
        if (umbraco.cms.businesslogic.member.Member.GetCurrentMember() == null)
        {
            <div>This happens!  Member logged on but member is null - how?</div>
        }
        else
        {
            <div>Member logged on and there is a member - happy days!</div>
        }
    }
    

    Can anyone explain how/why this happens and how to fix it? I'm perplexed by how it works as expected locally but not on staging.

    Umbraco 6.1.6, MVC.

    Thanks folks.

  • Marcio Goularte 388 posts 1360 karma points
    Jan 10, 2014 @ 19:45
    Marcio Goularte
    1

    Hi dan,

    Try this:

     

    if(System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
    {
       
    if(umbraco.cms.businesslogic.member.Member.GetCurrentMember()==null)
       
    {
           
    <div>This happens!  Member logged on but member isnull- how?</div>
       
    }
       
    else
       
    {
           
    <div>Member logged on and there is a member - happy days!</div>
       
    }
    }
  • Dan 1288 posts 3921 karma points c-trib
    Jan 13, 2014 @ 09:36
    Dan
    0

    Hi Marcio,

    I've tried this but it does the exact same thing. System.Web.HttpContext.Current.User.Identity.IsAuthenticated is true yet umbraco.cms.businesslogic.member.Member.GetCurrentMember() is null.

    The issue is that umbraco.cms.businesslogic.member.Member.GetCurrentMember() should not be true because I'm not logged in. Very odd!

    Any ideas as to what might be causing this?

    Thanks,

    Dan

  • Charles Afford 1163 posts 1709 karma points
    Jan 13, 2014 @ 22:14
    Charles Afford
    1

    I have had the same thing you need to use the ASP Membership.

    Membership.GetUser() will get you the current Logged on member :)
    Charlie
  • Dan 1288 posts 3921 karma points c-trib
    Jan 15, 2014 @ 16:40
    Dan
    100

    Thanks Charlie,

    This turned out to be a server-side issue to do with authentication modes; basic authentication was switched on, hence the weird behaviour - the code itself was actually okay.

Please Sign in or register to post replies

Write your reply to:

Draft