mvc render partial view without httpContext or controller context

ぐ巨炮叔叔 提交于 2020-01-14 10:33:13

问题


Is it possible to render partial view without ViewContext or ControllerContext?

  • I'm trying to get PartialView Html as string from outside of Controller Action.
  • OR
  • Is it possible to call Controller Action from another method? (this will allow me to execute controller action and get partial view html this way).

回答1:


You can try the Razor Generator Visual Studio Extension. Basically you run the custom tool on your view and it will generate a class that you can pass a model into and it will generate a string.



来源:https://stackoverflow.com/questions/15896703/mvc-render-partial-view-without-httpcontext-or-controller-context

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!