<!DOCTYPE html> @{ var myDb = Database.Open("PeopleDatabase"); var people = myDb.Query("SELECT * FROM TestTable"); } <html> <head> <title>People Example</title> </head> <body> <ul> @foreach(var person in people) { <li>@person.FirstName</li> <li>@person.LastName</li> } </ul> </body> </html>
I know many of you will immediately want to force comparisons. That’s generally where internet conversations about WebMatrix, Razor, or even the Webforms vs MVC debates start going downhill. I think there needs to be a little perspective when looking at these things. These are not competing technologies. They are only options. No one is suggesting you rewrite your weather prediction services in Razor.
But this release isn’t just about the Razor View Engine. You could use Spark, NHaml, or create your own if you wanted to. This is why I think this release is significant. Microsoft has done a great job of taking care of the plumbing. Allowing developers and groups to do whatever they want with the view engine of their choice.
As for deployment, keep in mind this preview isn’t installed on the servers. You will need to upload a copy of the System.Web.Mvc.dll to your bin folder. On my machine, the path to the .dll is C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies.
Michael Ossou
Technical Support