Blazor Tutorial - Build your first Blazor app

Create your app

In your command prompt, run the following command to create your app:

In your terminal, run the following command to create your app:

Command prompt
dotnet new blazorserver -o BlazorApp --no-https

This command creates your new Blazor app project and places it in a new directory called BlazorApp inside your current location.

Navigate to the new BlazorApp directory created by the previous command:

Command prompt
cd BlazorApp

Take a quick look at the contents of the BlazorApp directory. Several files were created in the BlazorApp directory, to give you a simple Blazor app that is ready to run.

  • Program.cs is the entry point for the app that starts the server.
  • Startup.cs is where you configure the app services and middleware.
  • App.razor is the root component for the app.
  • The BlazorApp/Pages directory contains some example web pages for the app.
  • BlazorApp.csproj defines the app project and its dependencies.

Take note of the BlazorApp directory path as you will use it later in the tutorial.

Got an error?

If you receive a message similar to Template "Blazor Server App" could not be created. Access to the path 'C:\Windows\System32\BlazorApp' is denied, change your current directory to one where you have permissions to create a new folder and try to run the command again. If you can't resolve the issue, use the I ran into an issue button to get help fixing the problem.