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

时间:2020-12-04 19:10:22   收藏:0   阅读:42

 利用组件不借助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>")); } } }

 

 

原文:https://www.cnblogs.com/efreer/p/14087062.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!