C# 获取TagHelper中的标记内容
如果我有这样的标签:C# 获取TagHelper中的标记内容,c#,asp.net-core,asp.net-core-tag-helpers,C#,Asp.net Core,Asp.net Core Tag Helpers,如果我有这样的标签: <foo>Some content</foo> 一些内容 如何获取TagHelper中的内容 我在TagHelper或TagHelperContext上看不到任何内容 我正在尝试分析标记的内容。解决方案有点不直观,您可以通过TagHelperOutput.GetChildContentAsync()方法从TagHelperOutput获取内容 如果我们有这样的标签: 一些内容 然后 public override void Process(Ta
<foo>Some content</foo>
一些内容
如何获取TagHelper中的内容
我在TagHelper
或TagHelperContext
上看不到任何内容
我正在尝试分析标记的内容。解决方案有点不直观,您可以通过
TagHelperOutput.GetChildContentAsync()
方法从TagHelperOutput
获取内容
如果我们有这样的标签:
一些内容
然后
public override void Process(TagHelperContext context, TagHelperOutput output)
{
var childContext = output.GetChildContentAsync().Result;
var content = childContext.GetContent();
// content == "Some content"
}