Widget create variant not working

Hendrik Clercx asked on June 29, 2023 13:26

I converted a .NET framework 4.8 Kentico 13.0.111 to .NET core 6.

I noticed that the Widget variant functionality doesn't work anymore. The widgets that already had multiple variants configured still work on the MVC website. When I switch to another persona, I get to see the matching variant of that widget. I can also edit the content of a variant. However in the Page Builder functionality, for a new widget, I can't add new variants. That part doesn't seem to be working anymore.

So I open the Widget variant popup, I select the persona I want, I click on 'Add variant' but nothing happens at this point: Image Text

I don't see any error in my console, network tab or Kentico Event Log.

First it opens the modal, the info is fetched via this call:



response local

Then when selecting a persona, it triggers the validate action:


However, the response is not correct here. It should return something like this: (screenshot from working environment)

expected response

But the response is the same as the index method:

response local

Next to this, during my conversion I have this folder in my MVC project:

folder structure

I am trying to figure out of this is something generated by Kentico or added by previous developers? Since .NET core is using wwwroot to serve files, the Page Builder might miss some scripts? Do I need to move these files to wwwroot as part of the migration or can I just ignore this? I think these files came from installing Nuget Kentico.Xperience.AspNet.Mvc5 or Kentico.Xperience.Libraries

Any advice?

Correct Answer

Hendrik Clercx answered on July 3, 2023 16:22

Okay so apparently there was custom code behind the /index and /validate. Not sure how I missed this in the first place...

But this explains a lot...

public IActionResult Validate(IsInPersonaViewModel viewModel)
    if (!ModelState.IsValid)
        viewModel.AllPersonas = GetAllPersonas();
        return PartialView("Personalization/ConditionTypes/_IsInPersonaConfiguration", viewModel);

It was returning the same response as /index in case the model was not valid. And because I am using .net core, the property AllPersonas was not valid anymore when it was empty:

public class IsInPersonaViewModel
    [Display(Name = "Persona Code Name")]
    public string PersonaCodeName { get; set; }

    public List<IsInPersonaListItemViewModel> AllPersonas { get; set; }

An "?" solved it.

0 votesVote for this answer Unmark Correct answer

Recent Answers

Brenden Kehren answered on June 29, 2023 16:15

What was the project in before you converted it? Was it version 13 MVC5? Or an earlier major version like version 12? I believe that folder you're mentioning is part of an MVC5 project. I'd highly recommend installing the Dancing Goat .NET Core sample site and compare. That "Kentico" directory should NOT be there for a .NET Core 6 project.

Seems like you have some cleanup that needs to happen in your Core project.

0 votesVote for this answer Mark as a Correct answer

Hendrik Clercx answered on June 29, 2023 16:26

Was first MVC K12. Then upgraded to K13. Now doing the conversion from K13 framework 4.8 to K13 .NET core 6.

That's what I thought, I'll remove that folder. But unfortunately not related to the problem then...

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on June 29, 2023 16:38

As suggested, clean up your core project to closely match what the DancingGoat project has. Also review the DancingGoat CMS project and compare that as well. Since you "upgraded" the CMS vs. started with a new version, you may have some caching issues with the CMS javascript files.

0 votesVote for this answer Mark as a Correct answer

Hendrik Clercx answered on June 29, 2023 16:54

Production is running Kentico 13. There is not much changed during the conversion to .net core regarding the CMS app since that is still on framework 4.8.

I'll have a good look at the differences between DancingGoat and my MVC, see if there's anything important missing.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on June 29, 2023 19:28

Production CMS and public site are both on v13.0.111? Is the public site MVC5 or .NET 6?

As I mentioned prior, if you upgraded the CMS application, there could be lingering code out there. I'd suggest starting with a fresh copy of v13.0.111 and if you have any custom CMS code to migrate that into the project.

Once you review the DG base projects with your code, clear the cache for the CMS in your browser and get your project rebuilt, you should be set.

0 votesVote for this answer Mark as a Correct answer

Hendrik Clercx answered on July 3, 2023 12:39

Yes, they're both running v13.0.111. I did the following tests:


  • CMS version 1 (deployed on PROD)
  • CMS version 2 (current)
  • MVC version 1 (.NET framework, deploy on PROD)
  • MVC version 2 (.NET core, current)

The following combinations work (on local machine), I can create new widget variants:

  • CMS version 1 with MVC version 1 (as expected, also situation on PROD)
  • CMS version 2 with MVC version 1

These combinations do not work:

  • CMS version 1 with MVC version 2
  • CMS version 2 with MVC version 2

So the problem is not with the CMS. I compared with Dancing Goat project, but didn't find anything notable.

I tried disabling scripts both in Dancing Goat and in my working combination to break it but I wasn't successful with this. I was still able to create a widget variant.

I enabled all exceptions during debugging to see if it would catch something, but that wasn't the case.

Currently going through the DLLS of Kentico to see if I can find out why my response is not matching the one of the working combination. If anyone can help out where this code is situated? This '/isinpersona/validate'


0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.