asp.net core ViewComponent中直接返回HTML的方法!!! how to return html code direct from a viewcomponent with out a view.cshtml

 利用组件不借助view.cshtml的方法直接返回的方法

  how to  return html code direct from a  viewcomponent with out a view.cshtml


using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Html; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ViewComponents; namespace MySite.ViewComponents { [ViewComponent(Name = "TestViewComponent")] public class TestViewComponent : ViewComponent { public TestViewComponent() { } public IViewComponentResult Invoke() { return new HtmlContentViewComponentResult(new HtmlString("hello - <b>我是个王八蛋</b>")); } } }

 

 

asp.net core ViewComponent中直接返回HTML的方法!!! how to return html code direct from a viewcomponent with out a view.cshtml

上一篇:Javascript变量与方法


下一篇:Adnc如何本地调试 - 一个轻量级的.Net Core微服务开发框架