views:

1121

answers:

7

I know you can use several different view engines with ASP.NET MVC:

  • ASPX, obviously
  • NVelocity
  • Brail
  • NHaml
  • et al...

The default ASPX view engine seems to make the most sense to me, coming from an ASP.NET WebForms background.

But, I wanted to get an idea of the pros and cons of each and see what most people are using.

Which does StackOverflow use?

+2  A: 

Most people on the planet will just use ASPX because that's what they know. Another excellent benefit is the compiled-nature... so you not only get type-safety and intellisense, but you can get the perf benefit as well.

The drawback that I see is that it's so flippin' verbose. I converted an app to NVelocity and was astounded at how clean it looked. The problem is that there were a lot of things that didn't work with NVelocity (like your own custom view helpers) and there was a severe lack of documentation.

I added a feature to MvcContrib where you can register your own HtmlExtension types to it, but it's more of a bandaid until a better solution comes out.

Ben Scheirman
+5  A: 

NHaml is my favorite for its terseness. People either love it or hate it, given that it looks very different from a traditional "HTML with inserted code" template system like ASPX or NVelocity.

Edit:

@Ben,

There are other view engines which compile down (NHaml is one), so those do support custom HTML helpers. I wouldn't be surprised to see the currently interpreted view engines all eventually end up with a compilation model eventually.

Brad Wilson
+12  A: 

I use Spark. It has nice flow between HTML and code. Scott Hanselman also did a post on it with his weekly source code review posts. I am really digging it a lot. One of the major features is pre-compilation of your views.

Dale Ragan
+4  A: 

"Which does StackOverflow use?"

Web Forms.

I asked Jeff Atwood about his decision on his Tag Soup post. He didn't reply - I think he was busy hunting down a missing closing tag ;-)

Andrew Peters
+2  A: 

I've used NVelocity in the past. For the most part it makes the code really clean and simple to follow; however, it normally ends up just being a few ViewData variables which have been filled up by XSLT files before hand. So I guess really my View Engine would be both XSLT (which is a love/hate thing - Extension Methods make it really useful) and NVelocity.

chrisntr
+1  A: 

I've used NVelocity with MonoRail for some time but have recently switched to Spark for both Asp.Net MVC and MonoRail. The syntax seems very natural to me, but I guess that's to be expected. ;)

loudej
+1  A: 

Microsoft has recently announced a new view engine: Razor.

Looks pretty interesting: http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx

sectrean