top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

Differences between Razor and ASPX View Engine in MVC?

+2 votes
94 views
Differences between Razor and ASPX View Engine in MVC?
posted Feb 9, 2017 by Jdk

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

View Engine renders the view into HTML form to the browser. If we talk about a MVC application in the .Net Framework, it supports the following 2 view engines:

  • Razor View Engine
  • Web Form/Aspx View Engine
    Differences

Entry with ASP.NET MVC

Razor View Engine is an advanced view engine and introduced with MVC3. This is not a language but it is a markup syntax.
ASPX View Engine is the default view engine for the ASP.NET MVC that is included with ASP.NET MVC from the beginning.

enter image description here

Namespace

Razor View Engine supports System.Web.Razor.
ASPX View Engine supports System.Web.Mvc.WebFormViewEngine.

Layout /MasterPage

In Razor View Engine we use Layouts.
In ASPX View Engine we use masterPages.

enter image description here

PartialPage /WebUserControl

In Razor View Engine we use PartialPage.
In ASPX View Engine we use WebUserControls.

enter image description here

Extension

Razor View Engine has .cshtml (with C#) and .vbhtml (with VB) extension for views, Layout and Partial views.
ASPX View Engine has a similar extension as in a simple web application like .aspx for the views, .acsx for UserControls and .master for Master Pages.

enter image description here

Performance

Razor Engine is a little slow compared to Aspx Engine.
Aspx Engine is faster compared to Razor Engine.

Syntax

‘@’ symbol uses in Razor Engine to write the code. @Html.ActionLink("Login", "LoginView")
‘<%:’ delimiters use as starting point and ‘ %>’ use as ending point. You can write the code between them in ASPX Engine.
<%: Html.ActionLink("Login ", " LoginView ") %>

enter image description here

Cross-Site Scripting Attacks

Razor Engine prevents Cross-Site Scripting Attacks, in other words it encodes the script or HTML tags like <,> before rendering to view.
ASPX Engine does not prevent Cross-Site Scripting Attacks, in other words any script saved in the database will be fired while rendering the page.

answer Feb 14, 2017 by Shivaranjini
Similar Questions
+4 votes

When using aspx view engine, to have a consistent look and feel, across all pages of the application, we can make use of asp.net master pages. What is asp.net master pages equivalent, when using razor views?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...