Build your first web app with ASP.NET Core using Blazor

Run your app

Select the Run and Debug icon in the Activity Bar on the left side of your workspace.

Run application using VS Code run button

Select the blue Run and Debug button.

Visual Studio Code will open up a menu of launch configurations. Select C#: BlazorApp [Default Configuration].

Run application using VS Code run button

Then you need to select a debugger. Select C#.

Run application using VS Code run button

Wait for the app to launch in the browser. Once you get to the following page, you have successfully run your first Blazor app!

The home page of your site contains some text and presents several tabs on the left to click and explore.

You can stop the app at any time by clicking on the stop button in the top toolbar.

Run application using VS Code run button

To re-run your application, select the dropdown menu to the right of the run button in the top right, and select Run project associated with this file.

Run application using VS Code run button

The displayed page is defined by the Home.razor file located inside the Components/Pages directory. This is what its contents look like:

Components/Pages/Home.razor
@page "/"

<PageTitle>Home</PageTitle>

<h1>Hello, world!</h1>

Welcome to your new app.

It already contains the code that sets it as the homepage and displays the text Hello, world! and Welcome to your new app. The PageTitle component sets the title for the current page so that it shows up in the browser tab.

Got an error?

If you receive an error message saying "Your connection is not private" with error code NET::ERR_CERT_INVALID, try to restart all browser windows so the new certificate can be picked up by the browser and run the application again.

If you can't resolve the issue you're having, select the I ran into an issue button below to get help fixing the problem.

Continue