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

 

 

相关文章:

  • 2021-07-18
  • 2021-06-03
  • 2022-01-30
  • 2022-12-23
  • 2022-12-23
  • 2021-12-30
  • 2021-12-02
  • 2021-11-13
猜你喜欢
  • 2022-02-22
  • 2022-12-23
  • 2022-12-23
  • 2021-05-31
  • 2021-12-03
  • 2021-12-01
  • 2022-12-23
相关资源
相似解决方案