“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

Published Tuesday, July 06, 2010 6:01 AM by Fredrik N

Comments

# Twitter Trackbacks for ???Razor??? the new ASP.NET View Engine - Fredrik Norm??n [asp.net] on Topsy.com

Pingback from  Twitter Trackbacks for                 ???Razor??? the new ASP.NET View Engine - Fredrik Norm??n         [asp.net]        on Topsy.com

# re: “Razor” the new ASP.NET View Engine

Tuesday, July 06, 2010 3:44 AM by Torkel

I am really glad MS decided to do new view engine, looks way better than web forms, to bad they did not go with the more elegant spark view engine approach. Scott gu mentioned that they were working on making it easier to integrate 3rd party view enginges wih visual studio and get intellisense. I hope that is true.

# Microsoft WebMatrix – Easy way to build ASP.NET Web Sites

Wednesday, July 07, 2010 12:26 AM by Fredrik Normén

Yesterday Microsoft announced WebMatrix , a tool to build standalone ASP.NET Pages using the new Razor

# re: “Razor” the new ASP.NET View Engine

Wednesday, July 14, 2010 10:16 AM by zigomir

Will it be in ASP.NET Razor possible to use ASP.NET Ajax?

Leave a Comment

(required) 
(required) 
(optional)
(required)