Wednesday, 11 April 2012

Razor View Engine

Razor View Engine
Razor is the name of the new view engine in MVC 3. The ASP.NET view engine processes web pages, looking for special elements that contain server-side instructions. As we’ve noted earlier, the standard ASPX view engine relies on the <% and %> elements, which are familiar to all ASP.NET developers. With Razor, the MVC development team has  introduced a new set of syntax elements, centered on the @ symbol. By and large, if you are familiar with the <% %> syntax, you won’t have too many problems with Razor, although there are a few new rules. In this section, the Razor syntax  We aren’t going to supply an exhaustive Razor reference; think of this more as a crash course in the syntax.

see the following code example for Razar view engine 



Razor views have a file extension of .cshtml, as opposed to the .aspx extension used in previous MVC releases and in ASP.NET Web Forms. You can still use the ASPX view engine in an MVC 3 project, but we prefer the Razor engine, and it seems to be a strong area of focus for the Microsoft MVC development team.

No comments:

Post a Comment