Razor Vs ASPX and goal of Razor View.

Posted by  Joseph Rossignol
 387  View(s)
Ratings:
Rate this:

Please differentiate between Razor and ASPX and also the goal of Razor's view with example.

  1. Re: Razor Vs ASPX and goal of Razor View.

    The Razor is a markup syntax that lets us embedded server-based code into web pages using C# and VB.Net since it is not a programming language and it is a server-side markup language.

    The Razor has no ties to ASP.NET MVC because Razor is a general-purpose templating engine. We can use it anywhere to generate output like HTML. It is just like that ASP.NET MVC has implemented a view engine that allows us to use Razor inside of an MVC application to produce HTML.

    Razor Vs ASPX and goal of Razor View.

    We will have a template file which is a mix of some literal text and some blocks of code. We combine that template with some data or a specific model where the template specifies where the data is supposed to appear, and then we execute the template to generate our output.

    Razor Vs ASPX

    •  The Razor is much similar to how ASPX files work. The ASPX files are templates, that contain literal text and some C# code which specifies where our data should appear and also we execute those to generate the HTML for our application.
    •  The ASPX files have a dependency on the ASP.NET runtime to be available to parse and execute only those ASPX files but the Razor has no such dependencies.
    •  And also, unlike ASPX files, Razor has some different design goals.

    Goals

    The Microsoft wants Razor to be easy to use and easy to learn, and work inside of tools like Visual Studio so that IntelliSense is easily available, the debugger is available, but also they wanted Razor to have no ties to a specific technology, like ASP.NET or ASP.NET MVC.

    If users are familiar with the life cycle of an ASPX file, then they are probably aware that there is a dependency on the ASP.NET runtime to be available to parse and execute those ASPX files and also Microsoft wanted Razor to be smart, to make a developer's job easier.

Answer