How to Get HtmlHelper in MVC 6

风流意气都作罢 提交于 2019-12-24 11:09:33

问题


When using the MVC 6.0 beta1, I can see in the MVC source that there is a utility DefaultTemplatesUtilities.cs to GetHtmlHelper. But this HtmlHelper only returns formatted output that is setup in CreateViewEngine() method.

How can I create a viewEngine so that the normal html is rendered.

I need to get HtmlHelper through code and use it to generate some html. i.e. htmlHelper.EditorFor(model=>model.Property)


回答1:


You can get HtmlHelper using Dependency Injection to your controller constructor.

Check my Answer for more detailed code.



来源:https://stackoverflow.com/questions/27895578/how-to-get-htmlhelper-in-mvc-6

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