I'm trying to generate HTML to a string from a Razor component. I use the following code to do that:
var html = await _htmlRenderer.Dispatcher.InvokeAsync(async () =>
{
var pv = ParameterView.FromDictionary(parameters);
var output = await _htmlRenderer.RenderComponentAsync<TComponent>(pv);
return output.ToHtmlString();
});
It worked well, until I included a child component in the Razor component and try to render it. I got the following error:
'HttpNavigationManager' has not been initialized
I don't use any navigation logic in the parent, nor in the child component. How can it be fixed?