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

If the dotnet new webapp <OPTIONS> command loads the dotnet new command help instead of creating a new Razor Pages app, install .NET Core SDK 2.1.300 or later. As of .NET Core SDK 2.1.300, the webapp Short Name is an alias for razor.

  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