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

To be able to run and debug, please ensure you do not have any files open at the editor. Select the blue Run and Debug button.

You need to select a debugger. Select C#.

Debugger selection dropdown

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

Select your Blazor App launch configuration

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.

Button to stop the application

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.

Button to run the application

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.