In an ASP.NET Core app I want to return custom html from a ViewComponent. I can return custom text, but the html will be encoded instead of being embedded:
public class BannerViewComponent : ViewComponent
{
public async Task<IViewComponentResult> InvokeAsync(string param1, int param2)
{
return Content("<strong>some custom html</strong>");
}
}
I use it in my .cshtml page:
@await Component.InvokeAsync("BannerView")
On the page this will Show as <strong>some custom html</strong>
instead of some custom html.
How do I directly return HTML instead of text from the ViewComponent?