Try our conversational search powered by Generative AI!

Site does not run when Refreshing personalization



I am currently follwing post:

I have added in the appropriate app settings for episerver:personalization.Site and episerver:personalization.ClientToken and have added

UsingPersonalization() extension method to the search query. Up this point the site runs fine.

However when I add the Controller Attribute:


or use the below code to refresh the personalization:

System.Threading.Tasks.Task.Factory.StartNew(currentContext => { 
System.Web.HttpContext.Current = (HttpContext)currentContext; 
 }, System.Web.HttpContext.Current.ApplicationInstance.Context);

my site won't wont run at all and gives the following object reference error:

[NullReferenceException: Object reference not set to an instance of an object.]
   EPiServer.Find.Personalization.ClientExtensions.Personalization(IClient client) +22
   EPiServer.Find.Personalization.RefreshPreferencesAttribute..ctor() +43
   System.RuntimeTypeHandle.CreateCaInstance(RuntimeType type, IRuntimeMethodInfo ctor) +0
   System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +1476
   System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit) +160

Any help as to why this would be greatly appreciated!



Jun 18, 2018 16:06

Hi Martin,

Are you able to confirm that the Find index configured in the web.config is valid?

Jun 18, 2018 16:26

Hi Johnny,

Yes it is a valid developer licsence that I generated. It is full of content too after I indexed.

Jun 18, 2018 16:35

Hi Martin,

I too have tried the RefreshPreferences attribute and can confirm that i reproduced the same exception as you. This will need to be raised as a bug with the Personalization team.

However I got it working using the other method.

First ensure you are injecting the IClient dependancy correctly into the controller constructor.

You can confirm that the IClient dependancy has been injected in correctly by setting a breakpoint in your code and inspecting the client object. You should be able to inspect the client object after the dependancy is injected to find your Personalization settings

Once you are happy the client is being set correctly, simply add the following code to the index of your controller

            System.Threading.Tasks.Task.Factory.StartNew(currentContext =>
                System.Web.HttpContext.Current = (HttpContext)currentContext;
            }, System.Web.HttpContext.Current.ApplicationInstance.Context);
Jun 19, 2018 17:19
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.