I heard viewengines like Razor or NHaml is giving much performance than WebForm View engine. Can someone advice me if this is true and which will be the best view engine
-
In a recent (December) web conference, Scott Hanselman stated that Razor is faster than the WebForms view engine. Although any performance benefits are relatively minor. – Dan Atkinson Jan 08 '11 at 14:05
4 Answers
If changing the view engine significantly impacts performance, there is something wrong with your design. Views are for simple display of properties in the model - nothing in there would be taking nearly as long as things like database access which happen in the controller. An order of magnitude improvement in the view rendering probably wouldn't be a noticeable difference in the time for the whole request.
MVC 3 may perform better than MVC 2, but that's just a matter of using the latest version which has improvements in all parts of the system. View engine choice is about your preferred syntax, not performance.

- 16,074
- 2
- 43
- 51
MVC 3.0 still in development, so in final release performance will be even much better i guess.
Here is some Razor tests ASP.NET MVC 3 Razor performance and asp.net mvc3 razor documentation? and of cause http://haacked.com/

- 1
- 1

- 26,767
- 13
- 87
- 104
I would expect that the WebForms view engine and Razor view engine to yield similar performance as they are built on similar principles. Both work by parsing a file (ASPX vs CSHTML) to generate a codedom which itself is used to generate a compiled class. The big difference comes in the optimisations built into the parsers/code generators used by each.

- 60,571
- 9
- 104
- 129
Don't know about the exact performance between Webforms and MVC. Been working with webforms for a while and i'm currently working with MVC2 and experimenting with MVC3's Razor View Engine.
Though MVC3 is still in the RC2 state the performance is pretty good but i guess it still have to be tweaked before the final release .Rumours are that the performance should be equal to MVC2. If you ask me i think that MVC2 and the new Razor Engine aren't any slower than Webforms applications. But personally i find the code easier maintainable with MVC, that's for me the biggest reason i switched from Webforms to MVC. Don't know anything about NHaml, but would personally choose Razor, works great! It's easy to use, understandable and gives good and clean code.
EDIT:
Read Scott Guthries blogs about the MVC3 RC2 candidate. He talks about performance. See this link.
Another topic on SO already exists about performance. Read it here
It always interessting to follow the blog pages of Scott Guthrie and Phil Haacked. Both work at Microsoft and regular post about MVC3.