Search⌘ K
AI Features

Razor Pages Overview

Explore the core concepts of Razor Pages in ASP.NET Core, understanding how to structure web pages with integrated UI and logic through .cshtml files and page models. Learn about convention-based routing and setting up necessary services to build small to medium-sized applications efficiently.

Razor Pages is a feature in ASP.NET Core that simplifies building web applications by combining the power of the Razor view engine with a structured, page-focused programming model. It was introduced in ASP.NET Core 2.0 and has gained popularity for its simplicity and ease of use, particularly for building small to medium-sized web applications.

Here are some key features and concepts associated with Razor Pages in ASP.NET Core:

  • Page-oriented model: Razor Pages encourages developers to organize their code around individual web pages or views. Each Razor Page is a self-contained unit that combines the UI (HTML) and the associated logic (C# code) for that page.

  • The .cshtml file: Razor Pages uses .cshtml files (Razor views) to define the page's UI, just like a view in a traditional ASP.NET MVC. These .cshtml files can include both HTML markup, C# code, and Razor syntax that links the two ...