問:有沒有方法使用IHtmlHelper擴展來呈現標記助手的輸出?HtmlHelper在MVC 6中呈現嵌套標籤助手vNext
信息:我使用ASP.NET 5/MVC 6(vNext)呈現在查看以下內容:
<cache expires-after="@TimeSpan.FromSeconds(5)">
<div custom-tag-helper-parm="9289"></div>
</cache>
我現在有一個的HtmlHelper擴展方法寫此位的HTML:
public static HtmlString RenderPortalContent(this IHtmlHelper HtmlHelper, string customTagHelperParm)
{
var output = [email protected]"<cache expires-after='{@TimeSpan.FromSeconds(5)}'>
<div custom-tag-helper-parm = '{customTagHelperParm}'>
</div>
</cache>";
return new HtmlString(output);
}
目前,正如所料,HTML是字面輸出。換句話說,<cache>
和custom-tag-helper-parm
TagHelpers都不被處理。
有沒有辦法使用像這樣的IHtmlHelper擴展來呈現標記助手的輸出?
你到底想要做什麼?具體來說,你想用「customTagHelperParm」做什麼?你打算怎麼打電話給這個幫手? –
你可以創建自己的標籤助手來呈現嵌套標籤助手,而不是呈現嵌套標籤助手的HTML助手。例如見[這個答案](http://stackoverflow.com/questions/32692857/nesting-taghelpers-in-asp-net-5-mvc-6/32695324#32695324) –