Try our conversational search powered by Generative AI!

BUG: ViewComponentContext.ViewContext.ViewData.Values is null after upgrade to 12.20.3



On some blocks I have this code snippet in order to get which size the block has.

var renderSettings = ViewComponentContext.ViewContext.ViewData.Values.FirstOrDefault() as Dictionary<string, object>;
var tag = renderSettings["tag"] as string;

After upgrade to 12.20.3 ViewComponentContext.ViewContext.ViewData.Values are null all of a sudden, which seems like a bug.

On another site we try to fetch customcss (that's added as an additionalViewData in ContentArea PropertyFor) which also is null all of a sudden after upgrade.


I can't pinpoint exactly which package that broke this, but these are the packages I've updated:

<PackageReference Include="EPiServer.CMS.AspNetCore" Version="12.20.3" />
<PackageReference Include="EPiServer.CMS.AspNetCore.HtmlHelpers" Version="12.20.3" />
<PackageReference Include="EPiServer.CMS.AspNetCore.Mvc" Version="12.20.3" />
<PackageReference Include="EPiServer.CMS.AspNetCore.Routing" Version="12.20.3" />
<PackageReference Include="EPiServer.CMS.AspNetCore.TagHelpers" Version="12.20.3" />
<PackageReference Include="EPiServer.CMS.AspNetCore.Templating" Version="12.20.3" />
<PackageReference Include="EPiServer.CMS.Core" Version="12.20.3" />
<PackageReference Include="EPiServer.Framework" Version="12.20.3" />
<PackageReference Include="EPiServer.Framework.AspNetCore" Version="12.20.3" />

It worked as expected in 12.20.1

Edited, Feb 26, 2024 12:05

Shouldn't you be able to access that using the ViewBag?


Feb 26, 2024 14:49

Just checked and ViewBag.customcss (or whatever I'm looking for) is empty.

Feb 26, 2024 15:07

Any news on if this is ineed a bug or if it's suppose to be this way?

Mar 12, 2024 7:20

The bug is now being fixed and will be released in next version 

bug number to track CMS-32835

our apologies for any inconvenience it might have caused. 

Mar 12, 2024 7:36

Great, thank you for the update!

Mar 12, 2024 7:37

Just upgraded to the latest version and we still have the issue with both ViewBag and ViewData:

I've also tried remaking my block until a bare minimum Async version, but still both the ViewData and ViewBag are empty.

Here are my installed packages:

Am I missing something here? 

Edited, Mar 21, 2024 8:01

I will relay the message to the developer who fixed the bug and will get back to you . 

Mar 21, 2024 8:06

This is the response I've got

There are some special tags that will not be passed along when you have nested content areas, Other custom keys should be passed along

That is due to the related issue [CMS-27573]

If the partner would like to pass along view data in a nested content area, I guess they could do it like this in the nested view:

@Html.PropertyFor(m => m.ContentArea, { Tag = ViewData["tag"} )

Mar 21, 2024 8:19

What we're trying to pass along are these standard "Display As".

I tried implementing the PropertyFor you suggested in ContainerBlock (the parent of ContainerColumnBlock) as well as on the ContainerColumnBlock but the ViewData and ViewBag is still empty.

Mar 21, 2024 8:57

You probably want to make sure you updated EPiServer.Cms.AspNetCore.HtmlHelpers to 12.21.1, not just the cms.core

Mar 21, 2024 12:55
sebp - Mar 22, 2024 9:25
After installing EPiServer.Cms.AspNetCore.HtmlHelpers it seems to have resolved the issue for us, thanks :)
* 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.