This Razor View engine is a part of new rendering framework for ASP.NET web pages. It rendering uses opening and closing brackets to denote code (<% %>) similar classic asp code, whereas Razor allows a cleaner, fluid syntax for determining where code blocks start and end.
One of the benefits is that Razor views can be rendered inside unit tests; this is something that was not easily possible with the previous ASP.Net renderer.
The biggest benefit is that the code is more succinct. The VS editor will also have the itellesense support that some of the other view engines don't have.
Example
Aspx engine
<% for (int i=0; i<10; i++)
{ %>
<li><%: i %></li>
<% } %>
By using Razor:
<ul>
@for (int i=0; i<10; i++)
{
<li>@i</li>
}
</ul>
No comments:
Post a Comment