Try our conversational search powered by Generative AI!

Asp.Net Idenity CurrentContact is Null


Hi, I am trying to add commerce to a default Alloy installation, I have been referencing the QuickSilver repo as a guide.

I created the registration /login process and this all works fine. However when I try to get the CurrentContact using the below code it is always null. 

var customerContact = CustomerContext.Current.CurrentContact;

Has anyone experienced similiar issues? or can explain why this would be?



Oct 24, 2017 20:41
var contact = PrincipalInfo.CurrentPrincipal.GetCustomerContact();

Will get or create and link the contact to the current principal usernamme. 

Oct 25, 2017 0:58

One possible cause is that commerce isn't initialized properly and then CustomerContext.Current won't get populated.

Oct 25, 2017 15:25

If you added "Commerce", by installing the EPiServer.Commerce package and adding the required database, it should properly initialized. 

Make sure PrincipalInfo.CurrentPrincipal is not null. If it null, then .CurrentContact will return null. 

Oct 26, 2017 9:49

Hi Guys, Thanks for the comments.

@Mark - I tried your suggestion, however this still returned null.

I am going to investigate this more, but thank you for your comments.

Oct 26, 2017 10:02

Hey Paul (and others),

Did you end up finding a fix for your isssue? I'm seeing the same on a client's install and trying to see what's causing the disconnect. They are also using Identity (rather than Membership), and I also checked out Quicksilver to make sure I'm not missing something critical, and the code looks pretty identical regarding customer contact creation. It's running Commerce 11.


Dec 05, 2017 23:00

Hi Maxim.

This is a kind of question that I'd suggest to contact developer support service. When we have all information we need to investigate it would be much faster than just guessing

Dec 06, 2017 8:24
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.