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

8 thoughts on “MVC 3: The Preview and why it’s important

  1. Do you plan on formally supporting WebMatrix for the next beta possibly (in the hosters list)? I have a project starting now that I thought I might start thinking about WebMatrix for, but I don’t want to jump the gun too much.

    Thanks.

  2. Microsoft has met with mixed reviews on the Webmatrix and Razor stuff. People can have their own opinions about Microsoft’s direction with all of this. But if this is going to be coming out, as a Microsoft focused hoster we will support these technologies when officially released.

  3. @Coolio
    – sloshing our business logic inline with our HTML.
    You could do that – or you could keep it in the model – point is, it’s up to you to control the quality.

  4. Problem: I was trying yo upload a published MVC 3 – Razor / EF4 -> SQLCE
    to your servers but I keep on getting errors.

    the first one was of a missing assembly (Web.Helpers) the last one was
    Unable to find the requested .Net Framework Data Provider. It may not be installed.

    Help

    1. The stuff you are using is still in beta. Some of it may be bin deployable but other things may require us to install stuff on the server. We do not install betas on the production server. When these items are officially released, we can make them available.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.