November Happy Hour will be moved to Thursday December 5th.

CookiePersonalizationEvaluator in episerver CMS 12

Vote:
 

Hello,

We upgraded CMS 11 to 12 using upgrade assistant and fixed package and other errors related to .Net core. Now when we run application we are facing this error in CookiePersonalizationEvaluator:

public class CookiePersonalizationEvaluator : IPersonalizationEvaluator
    {
        public const string PersonalizeCookieKey = "Personalize";
        private readonly ServiceAccessor<HttpRequest> _requestAccessor;
        public CookiePersonalizationEvaluator(ServiceAccessor<HttpRequest> requestAccessor)
        {
            _requestAccessor = requestAccessor;
        }
      public bool Personalize() => _requestAccessor()?.Cookies[PersonalizeCookieKey] != null;

}

"Unable to resolve service for type 'EPiServer.ServiceLocation.ServiceAccessor`1[Microsoft.AspNetCore.Http.HttpRequest]' while attempting to activate '..Business.Personalisation.CookiePersonalizationEvaluator' "

As per the document https://docs.developers.optimizely.com/content-cloud/v12.0.0-content-cloud/docs/disable-visitor-group-personalization it says to use HttpRequestBase but in .net core it doesn't support it.

Please help with this issue?

#283919
Edited, Jul 19, 2022 6:23
Vote:
 

I believe you now need to use Microsoft.AspNetCore.Http.HttpContext

Please see more info here : https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-context?view=aspnetcore-6.0 

#283987
Jul 20, 2022 9:15
* 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.