var writer = new System.IO.StringWriter();
var basedataTagHelper = new TagHelper_SelectBasedata(Generator, modelMetadataProvider) { //Url = Url.Action(baseData.Action, baseData.Controller), //remoteViewModel = baseData.ViewModel, //被调用TagHelper的配置参数 }; var basedataOutput = new TagHelperOutput("basedata", new TagHelperAttributeList(),(useCachedResult, encoder) => Task.Factory.StartNew<TagHelperContent>(() => new DefaultTagHelperContent())); var basedataContext = new TagHelperContext(new TagHelperAttributeList(), new Dictionary<object, object>(), Guid.NewGuid().ToString()); basedataTagHelper.ProcessAsync(basedataContext, basedataOutput).GetAwaiter().GetResult(); basedataOutput.WriteTo(writer, HtmlEncoder.Default);
//添加到当前TagHelper的DOM中
output.Content.AppendHtml(writer.ToString());
在TagHelper中使用一个类名为TagHelper_SelectBasedata的TagHelper
【TagHelper进阶系列】在TagHelper中使用其他TagHelper
原文:https://www.cnblogs.com/cdoneiX/p/12465392.html