ASP.NET CORE MVC - Development Environment

ASP.NET CORE MVC TUTORIAL SERIES · PART 0

Development Environment

Prepare an Xubuntu virtual machine based on Ubuntu 20.04.3 LTS, install the .NET 8 SDK from Microsoft's package repository, configure Visual Studio Code and C# development tools, and learn the terminal commands used throughout this ASP.NET Core MVC tutorial series.

Objective

By the end of this tutorial, your computer will be ready for developing ASP.NET Core MVC applications using .NET 8, C# and Visual Studio Code.

In this tutorial
  1. Understand ASP.NET Core
  2. Understand .NET, C# and MVC
  3. Review the technology stack
  4. Identify the Ubuntu version and computer architecture
  5. Register Microsoft's package repository
  6. Install and verify the .NET 8 SDK
  7. Explore the .NET command-line interface
  8. Install Visual Studio Code
  9. Install C# development tools
  10. Create the course working directory
  11. Verify the environment

1. What Is ASP.NET Core?

ASP.NET Core is Microsoft's cross-platform framework for developing modern web applications and web APIs using .NET.

ASP.NET Core applications can run on Linux, Windows and macOS.

In this tutorial series, we will use ASP.NET Core MVC to develop a Product Management System.

Important

ASP.NET Core is not a programming language. We will mainly write the application using C#.

2. .NET, C# and ASP.NET Core

TechnologyPurpose
.NETThe development platform and runtime.
C#The programming language used throughout this series.
ASP.NET CoreThe .NET framework for web development.
ASP.NET Core MVCAn ASP.NET Core architecture based on Model-View-Controller.
C# ↓ .NET ↓ ASP.NET Core ↓ ASP.NET Core MVC ↓ Web Application

3. What Is MVC?

MVC stands for Model-View-Controller.

ModelRepresents application data and related information.
ViewProduces the user interface displayed in the browser.
ControllerReceives requests and determines how the application responds.
Browser ↓ Routing ↓ Controller ↓ Action Method ↓ View ↓ HTML Response ↓ Browser

4. MVC versus Razor Pages

ASP.NET Core MVCRazor Pages
Uses separate controllers and views.Organises application behaviour around pages.
Explicitly demonstrates the MVC pattern.Can require fewer files for simple page-based applications.
Well suited for learning controller-based architecture.Well suited for page-focused applications.

5. Technology Stack

TechnologyPurpose
.NET 8Application development platform.
ASP.NET Core MVCWeb application framework.
C#Programming language.
Visual Studio CodeCode editor.
C# Dev KitC# development support in VS Code.
Entity Framework CoreDatabase access later in the series.
SQLiteApplication database.
Ubuntu/Linux TerminalRun development commands.
Course environment

The examples in this series target .NET 8. The commands in this Part 0 note match the confirmed virtual machine environment: Xubuntu based on Ubuntu 20.04.3 LTS (focal), username xubuntu, and x64/amd64 architecture.

6. Install the .NET 8 SDK

Step 1: Identify the Ubuntu release

Xubuntu is an Ubuntu flavour, so its package availability depends on the underlying Ubuntu release. Check it before choosing an installation method:

lsb_release -a

On the virtual machine used for this series, the important output is:

Distributor ID: Ubuntu
Description:    Ubuntu 20.04.3 LTS
Release:        20.04
Codename:       focal

The message No LSB modules are available may appear above the result. It does not prevent the command from reporting the Ubuntu release.

Step 2: Confirm the architecture

dpkg --print-architecture

The virtual machine used here reports:

amd64

This means it uses the x64 architecture supported by Microsoft's Ubuntu package repository.

Step 3: Understand the initial installation error

Installing directly from the original Ubuntu 20.04 package sources produces this error:

E: Unable to locate package dotnet-sdk-8.0
E: Couldn't find any package by glob 'dotnet-sdk-8.0'
E: Couldn't find any package by regex 'dotnet-sdk-8.0'

For this Ubuntu 20.04 environment, enabling universe is not sufficient. The .NET 8 package must be obtained from Microsoft's Ubuntu 20.04 package repository.

Step 4: Register Microsoft's Ubuntu 20.04 repository

Return to the home directory:

cd ~

Download Microsoft's repository configuration package:

wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb \
  -O packages-microsoft-prod.deb

Register the repository:

sudo dpkg -i packages-microsoft-prod.deb

Remove the downloaded configuration file because it is no longer needed:

rm packages-microsoft-prod.deb

Refresh the package index. The output should now mention packages.microsoft.com/ubuntu/20.04/prod:

sudo apt-get update

Step 5: Install the SDK

sudo apt-get install -y dotnet-sdk-8.0

The SDK installation also installs the .NET runtime, ASP.NET Core runtime, targeting packs and other required development components.

Step 6: Verify the successful installation

dotnet --version
dotnet --info

The confirmed SDK version in this environment is:

8.0.424

The important values from dotnet --info are:

.NET SDK:
 Version: 8.0.424

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  20.04
 RID:         linux-x64
 Base Path:   /usr/share/dotnet/sdk/8.0.424/

.NET SDKs installed:
 8.0.424 [/usr/share/dotnet/sdk]

.NET runtimes installed:
 Microsoft.AspNetCore.App 8.0.30
 Microsoft.NETCore.App 8.0.30
Support notice

Ubuntu 20.04 is now outside standard Ubuntu support. These commands document the confirmed working course VM, but a new long-term development environment should preferably use a currently supported Xubuntu LTS release such as Xubuntu 24.04.

7. Examine the .NET Installation

dotnet --info
dotnet --list-sdks
dotnet --list-runtimes

8. The dotnet Command

dotnet --help

Later in the series:

dotnet new
dotnet run
dotnet build
dotnet restore
dotnet add package
dotnet test
dotnet publish

9. Explore .NET Templates

dotnet new list

Look for the MVC template short name:

mvc
Do not create the project yet.

We will create the Product Management System in Part 1.

10. Install Visual Studio Code

The Snap Store connection on this VM returned a context canceled error. Install the official x64 Debian package instead.

Return to the home directory:

cd ~

Download the latest stable x64 package:

wget "https://update.code.visualstudio.com/latest/linux-deb-x64/stable" \
  -O code_amd64.deb

Install Visual Studio Code:

sudo apt install -y ./code_amd64.deb

Remove the downloaded installer:

rm code_amd64.deb

Verify and start Visual Studio Code:

code --version
code
Dependency repair

If the package manager reports missing dependencies, run sudo apt-get install -f, and then repeat the installation command.

11. Visual Studio Code Interface

ExplorerDisplays files and folders.
EditorUsed to edit source-code files.
ExtensionsAdds programming language and development support.
TerminalProvides an integrated command line.

12. Install C# Dev Kit

  1. Open Visual Studio Code.
  2. Open Extensions.
  3. Search for C# Dev Kit.
  4. Select the extension published by Microsoft.
  5. Click Install.

13. Create the Course Working Directory

cd ~
mkdir aspnet-mvc-tutorial
cd aspnet-mvc-tutorial
pwd

14. Open the Directory in Visual Studio Code

code .

The dot means the current directory.

15. Linux Path Concepts

Symbol or CommandMeaning
~Home directory.
.Current directory.
..Parent directory.
pwdDisplay the current path.
lsList directory contents.
cdChange directory.
mkdirCreate a directory.

16. Verify the Development Environment

dotnet --version
dotnet --info
dotnet --list-sdks
dotnet new list
code --version
cd ~/aspnet-mvc-tutorial
code .
Environment ready

If the commands work successfully and C# Dev Kit is installed, your development environment is ready.

17. Hands-On Exercise

  1. Display your current directory.
  2. Display the installed .NET SDK version.
  3. Display detailed .NET information.
  4. List installed SDKs.
  5. Return to your home directory.
  6. Create a directory called mvc-practice.
  7. Enter the directory.
  8. Display its full path.
  9. Open it in Visual Studio Code.
pwd
dotnet --version
dotnet --info
dotnet --list-sdks
cd ~
mkdir mvc-practice
cd mvc-practice
pwd
code .

18. Knowledge Check

  1. What is ASP.NET Core?
  2. What programming language will be used in this tutorial?
  3. What does MVC stand for?
  4. What is the purpose of a controller?
  5. Which command displays the installed .NET SDK version?
  6. What does pwd do?
  7. What does mkdir do?
  8. What does the dot mean in code .?
  9. Which Visual Studio Code extension provides C# development support?
  10. What repository is required to install .NET 8 on this Ubuntu 20.04 VM?
Show answers
  1. ASP.NET Core is a cross-platform .NET framework for building web applications and APIs.
  2. C#.
  3. Model-View-Controller.
  4. It handles requests and coordinates application responses.
  5. dotnet --version.
  6. It displays the current working directory.
  7. It creates a directory.
  8. It represents the current directory.
  9. C# Dev Kit.
  10. On this Ubuntu 20.04 VM, register Microsoft's Ubuntu 20.04 package repository, refresh the package index, and retry the installation.

19. Part 0 Summary

  • Learned the relationship between C#, .NET and ASP.NET Core.
  • Reviewed the MVC pattern.
  • Identified the confirmed environment as Ubuntu 20.04.3 LTS on amd64.
  • Registered Microsoft's Ubuntu 20.04 package repository.
  • Installed and verified .NET SDK 8.0.424.
  • Learned how to resolve the Unable to locate package dotnet-sdk-8.0 error.
  • Explored the .NET CLI.
  • Installed Visual Studio Code.
  • Installed C# Dev Kit.
  • Created a working directory.
  • Verified the development environment.
Next: Part 1 — Create Your First ASP.NET Core MVC Application

In Part 1, we will create the Product Management System using dotnet new mvc, examine the generated project structure, understand Program.cs, and run the application for the first time.