Practical.md - brainchildservices/curriculum GitHub Wiki

Slide 1

A Simple WebApp

his tutorial shows how to create and run an ASP.NET Core web app using the .NET Core CLI.

You'll learn how to:

  • Create a web app project.
  • Trust the development certificate.
  • Run the app.
  • Edit a Razor page.

Slide 2

At the end, you'll have a working web app running on your local machine

image

Prerequisites : .NET Core 3.1 SDK or later

Slide 3

Step 1: Open a command shell, and enter the following command:

 dotnet new webapp -o aspnetcoreapp

The preceding command creates a new web app.

The -o aspnetcoreapp parameter creates a directory named aspnetcoreapp with the source files for the app.

Slide 4

Step 2 : Trust the development certificate

 dotnet dev-certs https –trust`

The preceding command displays the following dialog:

image

Slide 5

Step 3 : Run the app

 cd aspnetcoreapp 

this will change the directory address to ~/aspnetcoreapp/, then enter

 dotnet watch run

After the command shell indicates that the app has started, browse to https://localhost:5001.

Slide 6

Step 4 : To Edit the content in your page

Open Pages/Index.cshtml and modify and save the page with the following highlighted markup:

  @page
  @model IndexModel
  @{
      ViewData["Title"] = "Home page";
  }

  <div class="text-center">
      <h1 class="display-4">Welcome</h1>
      <p>Hello, world! The time on the server is @DateTime.Now</p>
  </div>

Open Pages/Index.cshtml and modify and save the page with the following highlighted markup:

Browse to https://localhost:5001, refresh the page, and verify the changes are displayed.

Slide 7

  • TASK TO DO
    • Add another webpage to your latest created webapp, where a simple self intro of yourself can be shown. (Include your image).
⚠️ **GitHub.com Fallback** ⚠️