How to create a C# Web Application in Visual Studio Code and Debug
Prerequisites
You need .NET SDK and C# extension for Visual Studio Code installed.
Creating a Web App
Open a new terminal in Visual Studio Code.
Create a new web app with the following command.
dotnet new web --name MyWebApp1
Navigate to the created folder with this command
cd MyWebApp1
Open the code for the new application with this command. This will open a new window with the code of your new application.
code .
When you first open the code you’ll get a popup saying required assets to build and debug applications are missing, Add them? Click Yes.
This will create the launch.json and task.json files in the .vscode folder.
Debugging
Move to the Program.cs file and add a breakpoint.
Click on the Run menu option then select Start Debugging.
You will see that the program execution stops at the break point. You can debug as usual with the available buttons on top.