MVC3 ASP.NET - Introduction to Razor View EngineAdd to My Brief

Gareth Kelly | 5/04/2011

The latest release of Microsoft’s ASP.Net MVC is now shipped with a brand new view engine called Razor. This brand new syntax is responsible for parsing and compiling your views and partial views into C# so as to be able to render the view into HTML markup. It reads more like a devlopment language like C# rather than the old Classic ASP style scripting. It’s also very easy to learn.

This example is the old way of displaying a For Each loop using the traditional scripting syntax



Here is the same block of code using the new Razor syntax



You'll notice that the @ symbol is the new delimiter. You'll also notice that there is no closing delimiter. The Razor engine is extremely smart at figuring out the end of any code you write in your markup. There is also full  intellisense support for Razor in Visual Studio giving you a helping hand along the way.

I find as the page becomes more complex, the more Razor helps your code to be much cleaner with greater readability and with the bonus of having to write less to achieve this.

tags: Web DevelopmentOnline Trends

Interested in learning more?

Wiliam is a leading supplier of web solutions and can provide expert advice to assist your business or organisation online.

Make enquiry   Request quotation

Comments

Share this page

Print this page Email this page to a friend Bookmark and Share

No Brief added yet.

My Brief results-driven approach emphasises a commitment to our clients needs through strategic analysis and best-practice.

Add to My Brief

Click on this icon to save item into My Brief. Retrieve, email and print

Drag & Drop

Drag & drop any iten with this icon into My Brief. Retrieve, email and print

Search Blogs