Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)?
like image 817
Vaccano Avatar asked May 17 '19 17:05

Vaccano


People also ask

What are Razor pages?

- [Instructor] Razor Pages is a first-class web development framework that sits on top of the lightweight cross-platform and super fast ASP.NET Core runtime. Not only that, Microsoft is now recommending Razor Pages as the preferred way to build applications on the ASP.NET Core runtime.

What is the point of Razor pages?

From the docs, "Razor Pages can make coding page-focused scenarios easier and more productive than using controllers and views." If your ASP.NET MVC app makes heavy use of views, you may want to consider migrating from actions and views to Razor Pages.

What is the difference between Cshtml and Razor pages?

razor helps you embed serverside code like C# code into web pages. cshtml is just a file extension. razor view engine is used to convert razor pages(. cshtml) to html.

Should I use Razor pages?

Advantages of Razor Pages:Simple context of structure and has no controllers. Flexibility to fit any application you want to build. It has specific codes behind individual pages and is more organized. Build web apps in less time just like you did in ASP.NET Webforms.


1 Answers

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.
like image 92
Mike Brind Avatar answered Sep 30 '22 23:09

Mike Brind