Search code examples
razorrazor-pages

What is the difference between Razor and Razor Pages


My company is trying to setup some guidance on which technology to use for building applications. In doing my research I am getting confused.

It seems there are 3 ASP.NET technologies.

  1. MVC
  2. Razor
  3. Razor Pages

MVC is fairly clear to me as it has been around for a long time.

But I am getting confused between Razor and Razor pages. I can find lots of info on Razor Pages, but limited stuff that will compare them.

We are looking to target ASP.Net Core. So my questions are:

  1. Is Razor in ASP.NET Core?
  2. If so, is Razor "old" tech compared to Razor Pages? (Meaning does Razor Pages replace Razor?)
  3. What caused the need to build Razor Pages (instead of just building on Razor)?

Solution

  • Razor is a templating syntax that was introduced in 2010 as part of the ASP.NET Web Pages framework. It was also adopted as a view engine in ASP.NET MVC 3 at the same time.

    Razor Pages is a page-based web development framework that leverage the Razor templating syntax and sits on top of the ASP.NET Core MVC framework. It is the recommended framework for building page-focused server-side web applications in .NET Core. In other words, Microsoft are recommending that you do not use MVC for server-side HTML generation when you move the ASP.NET Core.

    So to directly answer your questions:

    1. Yes, and also in traditional ASP.NET
    2. Yes, Razor pre-dates Razor Pages
    3. MS felt that they needed to provide a page-centric web development model for .NET Core developers, rather than force everyone to use MVC.