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

Then, navigate to the new directory created by the previous command:

Command prompt
cd BlazorApp

What do these commands mean?

  • The dotnet new blazorserver command creates a new Blazor Server app for you.
  • The -o parameter creates a directory named BlazorApp where your app is stored and populates it with the required files.
  • The --no-https flag specifies not to enable HTTPS.
  • The command cd BlazorApp changes your current directory to the one just created for the new app.

What files were created?

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.

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.

Continue