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

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

Vote:
 

Hi

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.

ViewComponentContext.ViewData["customcss"]

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

#317750
Edited, Feb 26, 2024 12:05
Vote:
 

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

E.g

ViewBag.customcss
#317755
Feb 26, 2024 14:49
Vote:
 

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

#317756
Feb 26, 2024 15:07
Vote:
 

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

#318823
Mar 12, 2024 7:20
Vote:
 

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. 

#318824
Mar 12, 2024 7:36
Vote:
 

Great, thank you for the update!

#318825
Mar 12, 2024 7:37
Vote:
 

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? 

#319303
Edited, Mar 21, 2024 8:01
Vote:
 

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

#319304
Mar 21, 2024 8:06
Vote:
 

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"} )

#319306
Mar 21, 2024 8:19
Vote:
 

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.

#319310
Mar 21, 2024 8:57
Vote:
 

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

#319317
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 :)
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.