Razor/CSHTML - 对我们拥有的东西有什么好处? [英] Razor/CSHTML - Any Benefit over what we have?

查看:17
本文介绍了Razor/CSHTML - 对我们拥有的东西有什么好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都在使用新的 CSHTML 页面功能,并且发现他们更喜欢这种新的视图引擎语法,而不是现有的 ASP.NET MVC 默认视图引擎或 Web 表单,如果是这样,为什么?与 MVC 或 Web 表单相比,CSHTML 有何优势,反之亦然?

Anyone out there using the new CSHTML pages feature and is finding that they prefer this new view engine syntax over the existing ASP.NET MVC default view engine or over web forms, and if so, why? What about CSHTML gives you an advantage over MVC or web forms, or vice versa?

只是想听听人们对此的看法.

Just curious to hear people's take on it.

推荐答案

其中一个好处是 Razor 视图可以在单元测试中呈现,这在以前的 ASP.Net 呈现器中是不容易实现的.

One of the benefits is that Razor views can be rendered inside unit tests, this is something that was not easily possible with the previous ASP.Net renderer.

>

来自 ScottGu 的公告作为设计目标之一:

单元可测试:新的视图引擎实现将支持单元测试视图的能力(不需要控制器或网络服务器,并且可以托管在任何单元测试项目中——没有特殊的应用程序-需要域).

Unit Testable: The new view engine implementation will support the ability to unit test views (without requiring a controller or web-server, and can be hosted in any unit test project – no special app-domain required).

这篇关于Razor/CSHTML - 对我们拥有的东西有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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