Personalization API .NET - 'HttpRequestBase' does not contain a definition for 'GetCurrentPersonal

Hi:

I was downloading the KenticoCloud.Personalization SDK libraries (Personalization and MVC SDK) in a ASP.NET MVC project, but the following error is throwing when the method this.Request.GetCurrentPersonalizationSid() is placed in a controller code:

Error CS1929 'HttpRequestBase' does not contain a definition for 'GetCurrentPersonalizationSid' and the best extension method overload 'HttpRequestBaseExtensions.GetCurrentPersonalizationSid(HttpRequest)' requires a receiver of type 'HttpRequest'

I was reinstalling the libraries but the error appears again.

What can i do for solving the error?

Thanks.

Best Answer

Answers

  • petrs@kentico.com[email protected] Eindhoven, NLMember, Administrator, Kentico Staff admin

    Hi @cristhianalbertocaldasromero !
    Make sure you use ASP.NET MVC 5 or ASP.NET Core MVC 1.0 (running either on .NET Core or full .NET Framework).

    In case of ASP.NET MVC 5, you need to add KenticoCloud.Personalization.MVC NuGet package and the following using statement to your code: using KenticoCloud.Personalization.MVC;.

    In case of ASP.NET Core MVC use KenticoCloud.Personalization.AspNetCore NuGet package in combination with using KenticoCloud.Personalization.AspNetCore; statement.

    I just tested all the combinations and they seem to work fine. Let us know more about your project configuration if you still experience the error.

  • edited March 2017

    Hi:

    I was testing with a new ASP.NET MVC 5 project and adding KenticoCloud.Personalization.MVC package, but the error still appears. So i had to download the Personalization API SDK from GitHub and modified GetCurrentPersonalizationSid

    Before:

        public static string GetCurrentPersonalizationSid(this HttpRequest request)
        {
    

    After:

      public static string GetCurrentPersonalizationSid(this HttpRequestBase request)
       {
    

    And now the extension method works.

  • petrs@kentico.com[email protected] Eindhoven, NLMember, Administrator, Kentico Staff admin

    @cristhianalbertocaldasromero Are you using the latest version of the KenticoCloud.Personalization.MVC package?
    If you have a look in the source code, you'll see that overrides for both HttpRequest and HttpRequestBase are present: https://github.com/Kentico/personalization-sdk-net/blob/master/KenticoCloud.Personalization.MVC/HttpRequestBaseExtensions.cs

    public static string GetCurrentPersonalizationSid(this HttpRequest request); public static string GetCurrentPersonalizationUid(this HttpRequestBase request);

  • edited March 2017

    Yes, i downloaded the lastest version from GitHub to my computer, and i only overwrite the GetCurrentPersonalizationUid. But what was the reason of the change for the method GetCurrentPersonalizationUid? Beacuse before of the launch of Personalization API, the older API (KenticoCloud.Engage.MVC) had the extensive methods for HttpRequestBase:

  • petrs@kentico.com[email protected] Eindhoven, NLMember, Administrator, Kentico Staff admin

    Oh, I just noticed they are two different methods, not overloads. I think you are right, we should probably change it to HttpRequestBase. Let's discuss it with the Personalization team.

Sign In or Register to comment.