Razor pages are lightweight pages with the added functionality of handling requests directly without a controller. This makes them extremely useful to create a quick application, or a proof of concept or for presenting cool demonstrations to an audience. To make a View page into a Razor page, we need to add the @page directive. It should be the first directive on the page. For example:
@page<h1>Hello from .NET Core 2.0 By Example</h1>
Razor pages are useful when we need a View with small logic. For smaller logic, the return on investment would be better for Razor pages than that for creating a controller, actions, and view. In Razor pages, we can add logic inside the page or we can simply create code behind page.cshtml.cs, to ...