liveBook · Manning

Dotnet run

As explained in ASP.NET Core in Action, 3e

dotnet run is a .NET CLI command that builds and runs a .NET application from its project directory.

dotnet run builds and starts a .NET application from its project directory so you can open its URL and send requests to the running app. section 3.3 section 27.1.1

Use dotnet run when you want to:

  • Start a new ASP.NET Core application and view its basic response in a browser. section 3.3
  • Run a Razor Pages application and inspect its generated Home and Privacy pages. section 13.1.1
  • Execute the compiled application during development; use dotnet publish instead when preparing files for deployment. section 27.1.1

Run a Razor Pages application

Create the application with the .NET CLI, move into its project folder, and run dotnet run. The command starts the app, after which you open the reported URL and see the template’s Welcome page. Select Home or Privacy to check that navigation works. section 13.1.1

Figure 13.2 The output of your new Razor Pages application. The template chooses a random port to use for your application’s URL, which is opened automatically in the browser when you run the app.
CH13_F02_Lock3

The template chooses a random port, and the running Razor Pages application opens at that URL. section 13.1.1

How ASP.NET Core in Action, 3e covers it

How deep it goes
Defines execution and the project-folder context, then distinguishes running the application DLL from publishing deployment files.
Examples
Uses a Hello World endpoint, a Razor Pages Welcome page, Home and Privacy pages, and a randomly assigned application port.
What it assumes
Assumes a created .NET project and installed .NET tooling; the Razor Pages setup specifically requires .NET 7.
What you can do after
Operate/configure a .NET project by starting its application and opening the reported URL for testing.
How it connects
Connects .NET CLI execution with Visual Studio, dotnet build, dotnet publish, ASP.NET Core, and Razor Pages.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.