Difference between ASPX and Razor View Engine in MVC

By
There are two View Engines used in .NET Framework.
  1. ASPX/Web Form view engine
  2. Razor  view engine
There are some differences between ASPX View Engine ad Razor View Engine as give below:-
ASP.NET MVC Template:-
  • ASPX/Web Form View Engine is a default view engine for MVC 1 and MVC 2 template.
  • Razor view engine is an advanced view engine which was introduced with MVC 3 Template.Razor view engine is default view engine in MVC 3 template.  It is not language but it is a Markup Syntax .
Namespace:-
  • The Namespace for ASPX/Web Form engine is System.Web.mvc.Web Form view engine.
  • The Namespace for Razor view engine is System.Web.Razor
Layout/master page:-
  • We can use master page with ASPX view Engine.
  • We can use Layouts with Razor View engine.
File extensions:-
  • The file extensions used with ASPX view engine are  same as asp.net web forms. Ex. .aspx extension is used for views,.ascx extension is used for partial views ,WebUserControl and editor template and .master extension is used for master page layouts.
  • The file extensions used with Razor view engine are .Cshtml (Razor with C#) or .VBhtml (Razor with VB). 
Controls:-
  • In ASPX/ Web Form , we can use WebUserControls (.ascx).
  • But we can't use it with Razor view engine.  
Performance:-
  • ASPX view engine is faster than Razor view engine.
  • Razor view engine is little bit slower than ASPX engine.
Symbols:-
  • <% ..%> character is used for writing the ASPX view engine code.                                                   ex.   <%Html.ActionLink ("Login", "login_page")%>                      
  • The character @  uses with Razor view engine.                                                                            ex.  @Html.ActionLink ("SignUp", "Reg_page")
Look and Feel:-
  • ASPX view Engine support design mode, means you can see your page look and feel without running the mvc application.
  • Razor view engine does not support design mode in visual studio,means you can't see your page without running the application.
Cross site Scripting Attacks:-
  • ASPX view engine does not prevent cross-site scripting attacks (XSS Attack).Means any script saved in database will be fired while rendering the web page.
  • Razor view engine prevents the cross -site scripting attacks on web page.It encodes the script before rendering the view.
Testing Features:-
  • ASPX view engine does not support Test Driven Development (TDD) .This is more complex in unit testing.
  • Razor view engine support TDD (Test Driven Development). This is simple in unit testing.
Syntax:-
  • ASPX/Web Form syntax are not easy to learn.
  • But Razor syntax are easy to learn and clean than ASPX view engine.
Dependency :-
  • ASPX engine completely depends on System.web.UI.Page class.
  • Razore engine does not depends on System.Web.UI.Page class.

0 comments:

Post a Comment

Powered by Blogger.