ASP.NET MVC - 为什么不直接HtmlHelpers渲染到流? [英] ASP.NET MVC - Why don't HtmlHelpers render directly to the stream?

查看:85
本文介绍了ASP.NET MVC - 为什么不直接HtmlHelpers渲染到流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么ASP.NET MVC HTML辅助回报MvcHtmlString实例?这似乎相当低效分配一个字符串页面中的每个渲染帮手。为什么不助手直接渲染到的HtmlTextWriter的工作方式的WebForms控件一样?

Why do ASP.NET MVC HTML Helpers return MvcHtmlString instances? It seems rather inefficient to allocate a string for each rendered helper in a page. Why don't Helpers work the same way as WebForms Controls by rendering directly to a HtmlTextWriter?

推荐答案

MVC视图不仅可以用来制作HTML,但使用的模板系统,例如生产电子邮件。你会很容易在这里找到,在计算器上,方法直接渲染视图字符串。这也为您提供了更容易的可能性,以测试你的看法。

MVC Views can be used not only to produce HTML, but as a templating system used, for example, to produce e-mails. You will easily find here, on StackOverflow, method to render view directly to string. This also gives you easier possibility to test your views.

这篇关于ASP.NET MVC - 为什么不直接HtmlHelpers渲染到流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆