ASP.NET MVC Razor view engine

前端 未结 6 2043
醉梦人生
醉梦人生 2021-01-30 08:49

After reading Scott Guthrie\'s blog entry about the new Razor view engine for ASP.NET MVC and reading this question comparing the available view engines.

Razor seems to

6条回答
  •  清酒与你
    2021-01-30 09:42

    For me there are three compelling reasons:

    1. Compilation - Razor views can be compiled into a DLL. At last we get proper re-usability in .NET web projects. I can have a business object that knows how to display itself without having that code floating around as .ascx files in some part of the web project.

    2. Testability - as it's compiled to a class I can write a unit test and throw mocked instances of objects at it to see if the HTML is right.

    3. IntelliSense and the Terse Syntax are nice but not the most important parts.

提交回复
热议问题