3.9 KiB
title | author | description | ms.author | ms.custom | ms.date | uid |
---|---|---|---|---|---|---|
Get started with ASP.NET Core | rick-anderson | A quick tutorial that creates and runs a simple Hello World app using ASP.NET Core. | riande | mvc | 05/31/2018 | getting-started |
Get started with ASP.NET Core
This document provides steps for creating and running an ASP.NET Core app.
::: moniker range=">= aspnetcore-2.1"
-
Create an ASP.NET Core project. Open a command shell and enter the following command:
dotnet new webapp -o aspnetcoreapp
-
Trust the HTTPS development certificate:
Windows
dotnet dev-certs https --trust
The preceding command displays the following dialog:
Select Yes if you agree to trust the development certificate.
macOS
dotnet dev-certs https --trust
The preceding command displays the following message:
Trusting the HTTPS development certificate was requested. If the certificate is not already trusted we will run the following command: 'sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain <<certificate>>'
.
*This command might prompt you for your password to install the certificate on the system keychain.
Password:*
Enter your password if you agree to trust the development certificate.
Linux
See the documentation for your Linux distribution on how to trust the HTTPS development certificate.
-
Run the app:
cd aspnetcoreapp dotnet run
-
Browse to http://localhost:5001. Click Accept to accept the privacy and cookie policy. This app doesn't keep personal information.
-
Open Pages/About.cshtml and modify the page with the following highlighted markup:
-
Browse to http://localhost:5001/About and verify the changes are displayed.
[!INCLUDE next steps]
::: moniker-end
::: moniker range="= aspnetcore-2.0"
-
Create a new ASP.NET Core project.
Open a command shell. Enter the following command:
dotnet new razor -o aspnetcoreapp
-
Run the app with the following commands:
cd aspnetcoreapp dotnet run
-
Browse to http://localhost:5000.
-
Open Pages/About.cshtml and modify the page to display the message "Hello, world! The time on the server is @DateTime.Now":
-
Browse to http://localhost:5000/About and verify the changes.
[!INCLUDE next steps]
::: moniker-end
::: moniker range="<= aspnetcore-1.1"
-
Install the .NET Core SDK Installer for SDK 1.0.4 from the .NET Core All Downloads page.
-
Create a folder for a new ASP.NET Core project.
Open a command shell. Enter the following commands:
mkdir aspnetcoreapp cd aspnetcoreapp
-
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" } }
-
Create a new ASP.NET Core project.
dotnet new web
-
Restore the packages.
dotnet restore
-
Run the app.
dotnet run
The dotnet run command builds the app first, if needed.
-
Browse to
http://localhost:5000
.
[!INCLUDE next steps]
::: moniker-end