Sunday, May 15, 2011

MVC3 Razor View Engine

People who are facinated using MVC2 here is some thing interesting feature i would like to share "Razor Engine" in MVC3.
ASP.NET MVC 3 ships with a new view-engine option called “Razor” (in addition to continuing to support/enhance the existing .aspx view engine.

Reason for Raqzor Engine in MVC3.
ASP.NET MVC always supported the concept of “view engines” – which are the pluggable modules that implement different template syntax options. The “default” view engine for ASP.NET MVC today uses the same .aspx/.ascx/.master file templates as ASP.NET Web Forms. Other popular ASP.NET MVC view engines used today include Spark and NHaml.

You can have Razor view engine in drop view engine dropdown when you create a view in mvc3.

You denote the start of a code block with Razor using a @ character. Unlike code nuggets, Razor does not require you to explicitly close the code-block:

Layout.cshtml” layout-page that will define the common layout UI we want across our site. The “RenderBody()” method indicates where view templates that are based on this master layout file should “fill in” the body content:

Master pages are a part of the ASPX WebForms view engine, not the MVC framework so Razor cannot interoperate with it.

For more details visite ScottGu's Blog :