HtmlAttributeName doesn't take effect

I just upgraded to .NET8 so I dropped Newtonsoft.Json. Unfortunately, I have a problem with HTML serialisation. HtmlAttributeName don't take any effect.

Startup.cs

services.AddControllersWithViews();
services.AddMvc().AddControllersAsServices();
services.AddControllers().AddJsonOptions(options =>
{
    options.JsonSerializerOptions.PropertyNamingPolicy = null;
});
Serialized class
public class ToolTip
{
    [HtmlAttributeName("tooltipText")]
    [JsonPropertyName("tooltipText")]
    public string TooltipText { get; set; }
    
    [HtmlAttributeName("template")]
    [JsonPropertyName("template")]
    public string Template { get; set; }
}
Output.cshtml
<div class="control-wrapper">
    <div id="rteSection">
        <ejs-richtexteditor id="@Model.Id" e="" actionBegin="handleFullScreen" enableHtmlSanitizer="false" created="created" quickToolbarOpen="quickToolbarOpenEvent" change="change" focus="focus" saveInterval="1000" height="500" format="@Model.Format" toolbarClick="toolbarClicked">
            <e-richtexteditor-toolbarsettings items="@Model.Items"></e-richtexteditor-toolbarsettings>
            <e-richtexteditor-quicktoolbarsettings link="@Model.QuickToolbarLinkItems"></e-richtexteditor-quicktoolbarsettings>
            <e-richtexteditor-iframesettings enable="true"></e-richtexteditor-iframesettings>
            <e-richtexteditor-pastecleanupsettings plainText="true" allowedStyleProps="null"></e-richtexteditor-pastecleanupsettings>
            <e-content-template>
                @Model.Value
            </e-content-template>
        </ejs-richtexteditor>
    </div>
</div>

When I came back to Newtsoft.Json serialise it works.

services.AddControllers().AddNewtonsoftJson(options =>

 {

        options.SerializerSettings.ContractResolver = new DefaultContractResolver();

});

Output is TooltipText and Template. What am I missing? Thanks for your help.


1 Reply

SK Subathra Kaliamoorthy Syncfusion Team January 12, 2024 07:21 AM UTC

Hi Filip,


Based on your shared details and snippets, we are not able to pinpoint the issue from our perspective. To better assist you, could you please provide a detailed code snippet or a sample that demonstrates the problem? This will enable us to expedite the validation process with greater accuracy and provide a prompt solution.


Regards,

Subathra K


Loader.
Up arrow icon