问题
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