Razor vs WebForm(aspx)


RAZOR Web Form(ASPX)
Razor View Engine is an advanced view engine and introduced with MVC3. This is not a language but it is a mark-up syntax. ASPX View Engine is the default view engine for the ASP.NET MVC that is included with ASP.NET MVC from the beginning.
Namespace:System.Web.Razor. Namespace: System.Web.Mvc.WebFormViewEngine
Extension:.cshtml with C# or

.vbhtml with VB extension for views, partial views, editor templates and for layout pages.

Extension:.aspx extension for views

.ascx extension for partial views & editor templates and .master extension for layout/master pages.

RAZOR is much easier and cleaner than Web Form. It uses @ symbol in coding.
e.g.@Html.ActionLink(“link”, “click”)
ASPX Uses <% and %> delimiter in coding.
e.g. <%: Html.ActionLink(“link”, “Click”) %>
RAZOR engine comparatively slow but provides better security than ASPX. Razor Engine prevents XSS attacks(Cross-Site Scripting Attacks) means it encodes the script or html tags like <,> before rendering to view. Web Form is comparatively faster but less secure than RAZOR. Web Form Engine does not prevent XSS attacks means any script saved in the database will be fired while rendering the page
Razor Engine, doesn’t support design mode in visual studio means you cannot see your page look and feel without running application. Web Form engine support design mode in visual studio means you can see your page look and feel without running the application.
Razor Engine support TDD (Test Driven Development) since it is not depend on System.Web.UI.Page class. Web Form Engine doesn’t support TDD (Test Driven Development) since it depend on System.Web.UI.Page class which makes the testing complex.

 

Leave a comment