Business & Marketing
Health & Fitness

How to create .NET API Project in Visual Studio Code, and setting up Visual Studio Code to work with C#


Install .NET

Install the last version of .NET from here, and Download whatever the available version is for your computer.

download .NET

Install node

Because we’re going to use TypeScript and Angular on the client side of application, we also need a JavaScript engine to run our JavaScript App.

If you don’t have node installed on your PC, I would recommend you to use node.js with NVM ( Node Version Manager), which it allows you to quickly switch between different version of node. If you install nodes directly, then you need to uninstall and then reinstall a later version. But if you use NVM, will allow you to switch between different version of Node when you want. You can find the instruction on how to install Node.js with NVM here.

Installing node JS with NVM

Other wise, you can download the last stable version of nodejs (LTS), from the official website:

Create .net API project

First of all, we will create a solution file which will be a container for our project, and we will create a project template as well. And one that we’re going to use is the ASP.NET Core Web API

  • Create a new solution file: dotnet new sln
  • Create project template and give the output directory named API, because we want our API project to be contained in its own folder which will called simply API: dotnet new webapi -o API
  • Add the API project into solution: dotnet sln add API
Create .net API project

Now, we can open our project inside Visual Studio Code. If you don’t have VS code already installed in your pc, you can download for free form here.

.NET API in VS Code

Compile and debug C# code inside VS Code

In order to compile and debug C# code inside Visual Studio Code, we need to install some extensions:

  • C# for Visual Studio Code. This will give us development tools for .NET Core, editing support, IntelliSense, and Debugging support as well.
C# for Visual Studio Code

After that, go to View and select Command Pallete, and search for assets, and click on .NET Generate Assets for Build and Debug


The next extension what we need is C# Extensions. This extension will allow us to create classes by clicking a folder and creating new class and it’ll give us a template for that class.

C# Extensions for Visual Studio Code

Run The Application

Go in API folder and type the command:

dotnet run

This tells us is that our application is now listening on page to localhost:5001 and in localhost:5000. So we’ve got an HTTP address and we’ve got ass well an HTTPS address.

For this https address, we need to make sure our browser trust the certificate that is provided with .net SDK and what we need to do that is  tu use the command :

dotnet dev-certs https –trust

To check if the application working, type in browser:


If every thing work fine, you will get a page similar with this:

Congratulations, you’re done setting up the development environment for .NET API Project, and setting up Visual Studio Code to work with C#

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.