Advertisment

Doing More on ASP.NET with Razor

author-image
CIOL Bureau
Updated On
New Update

BANGALORE, INDIA: ASP.NET supports the concept of view engines. These are pluggable modules that implement different template syntax options. Other than Razor, the popular ASP.NET MVC view engines used these days include Spark and Nhaml.

Advertisment

Razor is a part of ASP.NET 3.0 MVC framework and it tries to integrate typical HTML and VB/C# code when developers are looking to implement mixed or inline coding process as part of creating web forms.

When compared to previous models, i.e. web forms and ASP.NET web pages model, ASP.NET Razor view engine is much more faster. It is primarily targeted at WebMatrix developers though it is also available to Visual Studio developers.

WebMatrix

Advertisment

WebMatrix includes a lightweight development tool, IIS Express, SQL Compact Edition, and a set of ASP.NET extensions that enable you to build standalone ASP.NET Pages using the new Razor syntax, as well as a set of easy to use database and HTML helpers for performing common web-tasks.

WebMatrix can be installed side-by-side with Visual Studio 2010 and Visual Web Developer 2010 Express. Size of this package is 15 MB and can be downloaded from http://www.microsoft.com/web/webmatrix . One point to keep in mind is that, if your system is not having .NET Framework 4.0 then your download size would become 50 MB.

Below is the sample code comparing previous model and the new Razor model:

Advertisment

With ASPX Code Nugget:

With Razor:

When we compare both of the above, we find that developers have to write 5 extra characters (< % = % >) in first block which is replaced by single charter (@) in second code block.

tech-news