AI OnAI Off
This thread helped me a lot! I was just about to rewrite my code and use a View component instead, when I found this!
Have found found any answers to why PropertyFor doesn't work?
No, We haven't implemented more Blazor/Razor components since then. Even though we'd like to do more blazor things it's a little too experimental for production for us right now.
However, the blocks we previously made are still in use and working. We render those in content areas with @Html.DisplayFor( ... )
I managed to get it working without too much of a hack: https://tedgustaf.com/blog/2024/blazor-in-optimizely-cms-12-with-.net-8
I think it's a viable workaround until Optimizely fixes the core issue.
I know that this is an extreme edge case but figured that anyone that's as curious as we are on Blazor and Razor components might run into this issue.
If you happen to build a Block that will end up rendering a Razor component with server interactivity you may end up with the following exception and stacktrace:
This issue seems to occur when you're rendering this block in a contentarea using @Html.PropertyFor(m => m.MyContentArea).
If you change @Html.PropertyFor to @Html.DisplayFor or use the new epi-property-taghelper - this problem does not take place.
Just to clarify, a block vith a view like this:
CounterBlock.cshtml
cannot be rendered using @Html.PropertyFor.
ArticlePage.cshtml
I pushed my examples to a new empty CMS site if anyone wants run this themselves: https://github.com/KevinJCandlert/epi-razor-component-issue/tree/master
Yet I was able to reproduce it in my project.