Difference between ASPX and Razor View Engine in .Net
View Engine in .NET is responsible for rendering your code into good looking Interface. MVC uses the views to locate and render the views we are requesting from the controller through asp action. Views can contain server controls, html tags and can have programming code.
There are many view engine available like
- ASPX
- Razor
- Spark
- NHaml
- NDJango
- Hasic
- and many more
But most of the programmers prefer to user Razor view due to its convenience
There are Two View Engines used in Dot NET Framework.
- ASPX view engine and
- RAZOR view engine
There are some differences between ASPX View Engine and RAZOR View Engines . They are provided below :-
ASPX View Engine:
-
ASPX/Web Form View Engine is a default view engine for MVC 1 and MVC 2 template.
-
The Namespace for ASPX/Web Form engine is System.Web.mvc.Web Form view engine.
-
Master Page is used with ASPX view Engine.
-
ASPX View Engine has extensions like .aspx for the views, .acsx for UserControls and .master for Master Pages as in simple web application.
-
In ASPX/ Web Form, we can use WebUserControls (.ascx).
-
ASPX view engine works faster in comparison to Razor view engine.
-
<% ..%> Character is used for writing the ASPX view engine code. For Eg. <%Html.ActionLink ("Login”, login_page") %>
-
It supports design mode means you can see your page look and feel without running the mvc application
-
ASPX view Engine Does not Support Test Driven Development (TDD).This is more Complex unit testing.
-
ASPX/Web Form syntax are difficult to learn in comparison to Razor view.
-
ASPX View engine completely depends on System.web.UI.Page class.
RAZOR View Engine:
-
Razor view engine is an advanced view engine which was introduced with MVC 3 . Razor view engine is default view engine in MVC 3 template.It is a Markup Syntax and not a language.
-
The Namespace for Razor view engine is System.Web.Razor
-
Layouts can be used with Razor View engine.
-
Razor View Engine has .cshtml (with C#) and .vbhtml (with VB) extension for views, Layout and Partial views.
-
We can't use WebUserControls with Razor view engine.
-
Razor view engine is a bit slower in comparison to ASPX engine.
-
The character @ is used with Razor view engine. Ex. @Html.ActionLink ("SignUp","Reg_page")
-
It doesn’t support design mode in visual studio, means you can't see your page without running the application.
-
Razor view Engine Support Test Driven Development (TDD. This is simple in unit testing.
-
Razor syntax is easy to learn and clean than ASPX view engine.
-
Razor View engine does not depends on System.Web.UI.Page class.
Also Read: Learn about different Web Services