The
Razor syntax is template mark-up syntax, based on the C# programming language
that enables the programmer to use an HTML construction workflow.
Web Form Engine is the default view engine for the Asp.net MVC that is built-in
with Asp.net MVC.
Razor
View Engine
- Razor Engine is an advanced view engine that was introduced with MVC3. This is not a new language but it is new mark-up syntax.
- The namespace for Razor Engine is System.Web.Razor
- The file extensions are different from Web Form Engine. It has .cshtml for C# and .vbhtml for VB.
- Razor has new and advance syntax that are compact, expressive and reduces typing.
- Razor syntax is easy to learn and much clean than Web Form syntax. Razor uses @ symbol to make the code start. For example @Html.ActionLink("SignUp", "SignUp")
- Razor Engine prevents Cross-Site Scripting (XSS) Attacks which means it encodes the script or html tags like <,> before rendering to view.
- Razor Engine is bit slower when comparing to Webform Engine.
- Design mode is not supported by Razor Engine in visual studio so user cannot see the page look and feel.
- Razor Engine supports Test Driven Development (TDD) since it is not depend on System.Web.UI.Page class.
Web
Form View Engine
- Web Form Engine is the default view engine for the Asp.net MVC that is built-in with Asp.net MVC.
- The namespace for Webform Engine is System.Web.Mvc.WebFormViewEngine.
- The file extensions used are same like Asp.net Web Forms. It has .aspx extension for views, .ascx extension for partial views & editor templates and .master extension for layout/master pages.
- Web Form Engine has the same syntax like Asp.net Web Forms uses for .aspx pages.
- Web Form syntax is borrowed from Asp.net Web Forms syntax that are mixed with html and at times make a view messy. Webform uses <% and %> delimiters to make the code. For example : <%: Html.ActionLink("SignUp", "SignUp") %>
- Web Form Engine does not prevent XSS attacks which means any script saved in the database will be fired while rendering the page.
- Web Form Engine is faster compared to Razor Engine.
No comments:
Post a Comment