【发布时间】:2017-02-01 14:40:47
【问题描述】:
在 ASP.NET Core 应用程序中,我想从 ViewComponent 返回自定义 html。我可以返回自定义文本,但 html 将被编码而不是被嵌入:
public class BannerViewComponent : ViewComponent
{
public async Task<IViewComponentResult> InvokeAsync(string param1, int param2)
{
return Content("<strong>some custom html</strong>");
}
}
我在我的 .cshtml 页面中使用它:
@await Component.InvokeAsync("BannerView")
在页面上,这将显示为 <strong>some custom html</strong> 而不是一些自定义 html。
如何直接从 ViewComponent 返回 HTML 而不是文本?
【问题讨论】:
标签: c# asp.net-core asp.net-core-viewcomponent