ASP.Net Core 2 Razor Pages

Once in a while, you just want a web page. In ASP.Net's MVC world, that means all the scaffolding and coding for Model, View and Controller. ASP.Net Core 2's Razor Pages simplifies all the plumbing to just getting the page done with the knowledge that it's all MVC underneath.

It's all about keeping it simple. In a typical MVC project, you'll need to jump around subfolders in your project, matching names here and there, and filling up skeletons/templates to create a page. Everything seems to be in order the way MVC should be. The folders and files are organized to be clearly and physically MVC -- as in the M, the V and the C. In reality, you're really just working on a single page.

Razor Pages can take the expressiveness of your web application up to the project level. You don't have to look for the M, the V and the C in three different places. MVC is implied -- it's all MVC underneath, yes, but your project doesn't need to scream it. Instead, all you see are the pages in your Pages folder. With Razor Pages, your website is not made up of Models and Views and Controllers. In the same way that we talk about the website having pages, your website project also speaks the same language -- the website is made up of pages and you can actually see them!

You know what this means? It means that Razor Pages has achieved abstracting MVC in to an engine up to the point that MVC doesn't really have to be physical and visual any more. With Razor Pages, it's like going back to the classic ASP days when a page can be coded just like writing a script... again.

Is it good? Well... I don't know. If you love MVC, using Razor Pages doesn't look and feel like MVC at all. I guess it's OK if you like the idea of the web project itself looking simpler to maintain, and the idea that the project itself is visibly organized in pages, instead of physical M, V and C codes.

Should you use it? If you've established a process in the team around the separation of M, V and C, which may include coding and testing guidelines, Razor Pages, to put it mildly, is quite breaking. You may need to add a section in your "black book" about it, like when to use it, where to use it, how to use it, code quality expectations, test requirements, etc. Or perhaps, you can just say, "Don't use it."

Razor Pages is in preview with ASP.Net Core 2.0. It's an engineering feat. I think it's worth checking out. I like how it re-organizes the web project in to pages. I also like how it makes creating webpages feel like scripting again. If you're working on a simple page and it feels like going through all the M-V-C drama is overkill, I suggest giving Razor Pages a go.

Comments