DiscountASP.NET

MVC 3: The Preview and why it’s important

We are approaching another milestone in ASP.NET MVC. This release offers improvements to the view that are rather significant. Specifically, MVC 3 allows you to easily use the View Engine of your choice for building your applications. It comes out the box with Razor, the View Engine that powers the new WebMatrix package. For those that haven’t touched it, Razor’s semantics reminds me of classic ASP. It’s essentially an inline coding model that leverages a lot of modern .NET but in a really simple way. Take a brief look and you will get the point.

<!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

Exit mobile version