Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Alessandro 1 post 71 karma points
    Sep 26, 2022 @ 15:23
    Alessandro
    0

    Error rendering custom macro inside Rich Text Editor: Value cannot be null. (Parameter 'content')

    Hi, I have a problem to rendering macro added to Rich Text Editor. After adding my custom macro to insert .mp4 video inside html, and I try to get value of this Rich Text Editor with this function content.Value<string>("description", culture), it return an error like this:

    "message": "Value cannot be null. (Parameter 'content') ",
    "stackTrace": "   at Umbraco.Cms.Web.Common.Macros.MacroRenderer.RenderAsync(MacroModel macro, IPublishedContent content)\r\n   at Umbraco.Cms.Web.Common.Macros.MacroRenderer.RenderAsync(String macroAlias, IPublishedContent content, IDictionary`2 macroParams)\r\n   at Umbraco.Cms.Core.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.<>c__DisplayClass7_0.<RenderRteMacros>b__1(String macroAlias, Dictionary`2 macroAttributes)\r\n   at Umbraco.Cms.Infrastructure.Macros.MacroTagParser.ParseMacros(String text, Action`1 textFoundCallback, Action`2 macroFoundCallback)\r\n   at Umbraco.Cms.Core.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.RenderRteMacros(String source, Boolean preview)\r\n   at Umbraco.Cms.Core.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.Convert(Object source, Boolean preview)\r\n   at Umbraco.Cms.Core.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, Object inter, Boolean preview)\r\n   at Umbraco.Cms.Core.Models.PublishedContent.PublishedPropertyType.ConvertInterToObject(IPublishedElement owner, PropertyCacheLevel referenceCacheLevel, Object inter, Boolean preview)\r\n   at Umbraco.Cms.Infrastructure.PublishedCache.Property.GetValue(String culture, String segment)\r\n   at Umbraco.Extensions.PublishedPropertyExtension.Value[T](IPublishedProperty property, IPublishedValueFallback publishedValueFallback, String culture, String segment, Fallback fallback, T defaultValue)\r\n   at Umbraco.Extensions.PublishedContentExtensions.Value[T](IPublishedContent content, IPublishedValueFallback publishedValueFallback, String alias, String culture, String segment, Fallback fallback, T defaultValue)\r\n   at Umbraco.Extensions.FriendlyPublishedContentExtensions.Value[T](IPublishedContent content, String alias, String culture, String segment, Fallback fallback, T defaultValue)\r\n   at UmbracoStandard.S4W.API.Models.Objects.NewsDetailDto.Map(IPublishedContent content, String culture, List`1 activeCultures, GenericSeo genericSeo, SeoPerDocument seoPerDocument) in C:\\GitProjects\\Zinelli e Perizzi\\Nuxt-Umbraco website\\umbraco\\UmbracoStandard\\S4W\\API\\Models\\Objects\\News\\NewsDetailDto.cs:line 47\r\n   at UmbracoStandard.S4W.API.Services.Mappers.Implementors.NewsDetailMapper.MapDetail(IPublishedContent content, IPublishedContent prev, IPublishedContent next, String culture) in C:\\GitProjects\\Zinelli e Perizzi\\Nuxt-Umbraco website\\umbraco\\UmbracoStandard\\S4W\\API\\Services\\Mappers\\Implementors\\NewsDetailMapper.cs:line 39\r\n   at UmbracoStandard.S4W.API.Controllers.NewsMarineDivisionController.GetDetail(String slug, String culture) in C:\\GitProjects\\Zinelli e Perizzi\\Nuxt-Umbraco website\\umbraco\\UmbracoStandard\\S4W\\API\\Controllers\\NewsMarineDivisionController.cs:line 41\r\n   at lambda_method6852(Closure , Object , Object[] )\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()\r\n--- End of stack trace from previous location ---\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()\r\n--- End of stack trace from previous location ---\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)"
    

    This is macro partial view:

    @inherits Umbraco.Cms.Web.Common.Macros.PartialViewMacroPage;
    
    @if (Model.MacroParameters["chooseAVideo"] != null)
    {
        var video = Model.MacroParameters["chooseAVideo"];
        <video controls autoplay width="500" height="300" src="@video"></video>
    }
    

    The macro work correctly in the text editor preview: enter image description here

    Umbraco version: 9.3.1

    What am I doing wrong?

    Thanks for your help.

  • Remko 118 posts 283 karma points
    Aug 01, 2023 @ 11:53
    Remko
    0

    I was wondering.. did you every manage to solve this? Still getting this exception in Umbraco 12...

  • Jonas Thierry 17 posts 98 karma points notactivated
    Oct 23, 2023 @ 09:59
    Jonas Thierry
    0

    I have noticed that if you delete the macro comment it works fine... I dont know if its helpful :-)

    I am also interested if a solution came up?

  • Zachary Allen 14 posts 85 karma points
    May 01, 2024 @ 17:18
    Zachary Allen
    0

    Still an issue in Umbraco 13

    Trying to render a Rich Text Editor, with a Macro, From a Controller will result in the error "Value cannot be null. (Parameter 'content')"

    Without a macro in the RTE it works fine, but any macro will cause the issue.

    UPDATE: It works with blocks! Convert your macro to a Block, and it should load with no issues.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies