
ASP.NET Core MVC vs. Razor Pages – A quick comparison - jonhilton
https://jonhilton.net/razor-pages-or-mvc-a-quick-comparison/
======
martin1b
Reminds me a lot of webforms.. Code behind per page. Page events (OnGet =>
Page_Load).

~~~
keithnz
It doesn't seem anything like webforms. This looks much more like most other
server side templating systems. It just couples the standard HTTP verbs to the
templates.

Webforms was this whole other beast that had UI controls connected to the
backend which heavily relied on synching state between the backend (through
page loads) and front end for user actions on those controls. It did mean you
could write a lot of your UI code in your server side language ( C# / VB.NET
).

~~~
hungerstrike
> UI controls connected to the backend which heavily relied on synching state
> between the backend...

This sounds like React with SSR or so-called Universal Web Apps.

~~~
Glide
So that feels like saying ASP.NET AJAX was way ahead of the game. And in some
ways it was.

And in other ways you had this massive __VIEWSTATE hidden input field that
would have to be sent in order to recreate state. But I will say, it was very
cool technology at the time.

------
noitsnot
In .NET Core with Razor pages requests just bypasses the Controller and hits
the OnGet() and OnPost(). They just eliminated the Controller in their 'MVC'.

------
james-skemp
"the new kid on the block, Razor Pages"

I'm not sure that's actually true? I thought I did cshtml pages without all
the MVC bits around MVC 3 or 4.

Is this perhaps just a branding/naming thing?

Update: Haven't found a good reference yet, but it seems to have been around
when WebMatrix was still supported, but I don't think I actually had to use it
to develop the site that was cshtml files.

Update 2: ASP.NET Web Pages with Razor Syntax was what it was called.
[https://docs.microsoft.com/en-us/aspnet/web-
pages/overview/g...](https://docs.microsoft.com/en-us/aspnet/web-
pages/overview/getting-started/introducing-aspnet-web-pages-2/getting-started)

I'm not going crazy!

~~~
nhebb
Razor pages != razor syntax. I think Microsoft screwed up with the naming of
them because, even within the .NET community, I see a lot of developers that
conflate them. Microsoft should have named razor pages something different to
avoid this confusion.

It's just a simplified MVC model where the controller boils down to OnGet()and
OnPost() methods in a code-behind file. The code-behind file, in turn, reminds
developers of web forms, but razor pages are really not similar at all.

ASP.NET Core has a lot of flexibility. You can go Web Api / SPA, classic MVC,
or razor pages. Each has a sweet spot.

~~~
james-skemp
Yeah, I know the syntax is different, and I think you're right across the
board. But I guess I kind of see it as just the next iteration of the old Web
Pages w/ Razor functionality, just with better support for external
models/code-behind, but also more package dependencies.

.NET Core definitely seems to be off to a great start, and once the tooling
gets better I think I'll use it much more (EF support via VS is lacking,
especially if you're trying to update a model going db-first).

So if the future of .NET is .NET Core first, I look forward to continuing to
be a .NET developer.

