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.

  3. Trust the HTTPS development certificate:

```console
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. Run the app:

    cd aspnetcoreapp
    dotnet run
    
  2. Browse to http://localhost:5001. Click Accept to accept the privacy and cookie policy. This app doesn't keep personal information.

  3. Open Pages/About.cshtml and modify the page with the following highlighted markup:

    @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>
    
  4. Browse to http://localhost:5001/About and verify the changes are displayed.

Next steps

  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
    
  3. Run the app with the following commands:

    cd aspnetcoreapp
    dotnet run
    
  4. Browse to http://localhost:5000.

  5. 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>
    
  6. 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
    
  3. 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" }
    }
    
  4. Create a new ASP.NET Core project.

    dotnet new web
    
  5. Restore the packages.

    dotnet restore
    
  6. Run the app.

    dotnet run
    

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

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

Next steps