Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Latest commit

 

History

History
47 lines (32 loc) · 2.68 KB

File metadata and controls

47 lines (32 loc) · 2.68 KB

Create a Razor Pages web app in Visual Studio Code

The following tutorial is based on "Get started with ASP.NET Core Razor Pages in Visual Studio Code" from docs.microsoft.com.

Prerequisites

Create a Razor web app

Enter the following commands in the terminal:

dotnet new razor -o RazorPagesMovie -f net7.0
cd RazorPagesMovie
dotnet run

Open a browser and browse to https://localhost:{PORT}/ to view the application. The {PORT} will be visible in the output in terminal.

Open project in VS Code

  • Shut down your application using Ctrl+C.
  • Open your project in VS Code using one of the following options:
    • Select File > Open Folder, and then select the RazorPagesMovie folder.
    • Enter the following command in the terminal code .
  • If you get the prompt Do you trust the authors of the files in this folder, select Yes, I trust the authors.
  • If you get the prompt Required assets to build and debug are missing from 'RazorPagesMovie'. Add them?", select Yes.

Project files and folders explained

The following table lists the files and folders associated in the project.

Name Description
wwwroot/ Contains all the static files. For example CSS, images, and so on.
Pages/ Contains Razor Pages and supporting files. Each Razor page is a pair of files:
- A .cshtml file that contains markup with C# code using Razor syntax.
- A .cshtml.cs PageModel class file that defines page handler methods and data used to render the page.
RazorPagesMovie.csproj Contains configuration metadata for the project, such as dependencies.
Program.cs Serves as the app's managed entry point and configures app behavior, such as routing between pages.

NEXT TUTORIAL: Adding a Model