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?
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).
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.
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.
MemberHelper.GetCurrentMember() Cannot perform runtime binding on a null reference
Hi
I'm experiencing an issue with the MemberHelper.GetCurrentMember()
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
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).
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
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.
is working on a reply...