Get started with ASP.NET Core

  1. Install the .NET Core 2.1 SDK or later.

  2. Create an ASP.NET Core project. Open a command shell and enter the following command:

dotnet new webapp -o aspnetcoreapp

Note

In ASP.NET Core 2.1 or later, webapp is an alias of the razor argument. If the dotnet new webapp <OPTIONS> command loads the dotnet new command help instead of creating a new Razor Pages app, install the .NET Core 2.1 SDK.

  1. Trust the HTTPS development certificate:
dotnet dev-certs https --trust

The preceding command displays the following dialog:

Security warning dialog

Select Yes if you agree to trust the development certificate.

  1. Install the .NET Core SDK 2.0 or later.

  2. Create a new ASP.NET Core project.

Open a command shell. Enter the following command:

dotnet new razor -o aspnetcoreapp
  1. Run the app with the following commands:
cd aspnetcoreapp
dotnet run
  1. Browse to http://localhost:5000.

  2. Open Pages/About.cshtml and modify the page to display the message "Hello, world! The time on the server is @DateTime.Now":

@page
@model AboutModel
@{
    ViewData["Title"] = "About";
}
<h2>@ViewData["Title"]</h2>
<h3>@Model.Message</h3>

<p>Hello, world! The time on the server is @DateTime.Now</p>
  1. Browse to http://localhost:5000/About and verify the changes.

Next steps

  1. Install the .NET Core SDK Installer for SDK 1.0.4 from the .NET Core All Downloads page.

  2. Create a folder for a new ASP.NET Core project.

Open a command shell. Enter the following commands:

mkdir aspnetcoreapp
cd aspnetcoreapp
  1. If you have installed a later SDK version on your machine, create a global.json file to select the 1.0.4 SDK.
{
"sdk": { "version": "1.0.4" }
}
  1. Create a new ASP.NET Core project.
dotnet new web
  1. Restore the packages.
dotnet restore
  1. Run the app.
dotnet run

The dotnet run command builds the app first, if needed.

  1. Browse to http://localhost:5000.

Next steps