Wednesday, 19 April 2017

Difference between RAZOR View Engine and ASPX View Engine

What is View Engine??

The view-engine is responsible for creating HTML from your views. Views are usually some kind of mix-up of HTML and a programming language(ie. C# or VB)
The view engine is what’s responsible for rendering your view, and converting your code into glorious HTML.

In ASP.NET MVC, a View Engine translates view into HTML by:

    Providing implementation of –

  • IViewEngine (as template provider)
  •  IView (as rendering template) and
  • Template Engine(ie Razor or aspx ) for parsing and compiling view file into executable code.
There are many view engines available and some of them are following:
  1. ASPX
  2. Razor
  3. Spark
  4. NHaml
  5. NDJango
  6. Hasic
  7. Brail
  8. Bellevue
  9. Sharp Tiles
  10. String Template
  11. Wing Beats
  12. SharpDOM
    Currently most developers prefer to use Razor view engine as it provides very convenient way of programming. All of these view engines may not support ASP.NET MVC , it supports the following 2 view engines:
    1. Razor View Engine        Razor is a markup syntax that allows you to embed server-side code (written in C# or VB) in an HTML markup.A file containing server-side code in the C# syntax has an extension of .cshtml. However, a file containing server-side code in VB has an extension of .vbhtml.
    2. Web Form/Aspx View Engine  ASPX or the Web Forms engine is the default view engine that is included in the MVC Framework since the beginning. Writing a code with this engine is similar to writing a code in ASP.NET Web Forms.

    Understanding Syntax Difference

Being software developer, we are normally concerned about code syntax differences when using either of these two View Engines. So, in order to get better understanding, please look into following code snippet written using both ASPX and Razor View Engine in order.
aspx

Detailed Difference Between ASPX View Engine and Razor View Engine

diff2


diff1

No comments:

Post a Comment