“Razor” the new ASP.NET View Engine
Because of my work with the www.forkcan.com and the traveling around Sweden talking about ASPEN a Silverlight 4, MVVM, RIA Services, Unity 2.0, MEF application I haven’t spend so much time with blogging.
“Razor” is a new view engine for ASP.NET, you can get more information about it on Scott Guthrie’s blog. Here is an example of a old server-side script block in ASP.NET:
<h1><%: title %></h1> <% foreach (var item in items) {%> <span><%: item.FirstName %> <%: item.LastName %></span><br/> <%{%>
With “Razor” the above code can look like this:
<h1>@title</h1> @foreach (var item in items { <span>@item.FirstName @item.LastName</span><br/> }
“Razor” uses a new file suffix “cshtml” or “vbhtml”, where the prefix is the language used in the file.
What I like the most with “Razor” is the new way to use expressions and the cleaner server-side code blocks.
If you want to know when I will publish a new blog post, then you can follow me on twitter: @fredrikn