Create .NET Core Web API (C#) In MonoDevelop On Ubuntu 18.04

One of the main advantages of using .NET Core Web API is the speed in transaction processing. In this tutorial, we will execute a .NET Core Web API 2.2 application using MonoDevelop as an IDE on Ubuntu 18.04.

Introduction

In this article, let us see how to install Mono Framework, MonoDevelop, and use it with .NET Core, by creating a new project (Web API) in MonoDevelop.

Step 1 - Installing Mono Framework

Create .NET Core Web API (C#) In MonoDevelop On Ubuntu 18.04 

In Ubuntu, open the CMD and run the following command.

  1. sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF  
  2. echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list  
  3. sudo apt update  
  4. sudo apt install mono-devel  
  5. mono --version  

This command will return the Mono 5.18 version details that confirm that the framework has been installed. (Now, you can build C# apps on Linux (GTK#, ASP.NET Web Forms, ASP.NET Web Services, Console Applications, etc).

Step 2 - Installing MonoDevelop (IDE)

Create .NET Core Web API (C#) In MonoDevelop On Ubuntu 18.04 

Open the CMD and run the following command

  1. sudo apt install apt-transport-https dirmngr  
  2. sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF  
  3. echo "deb https://download.mono-project.com/repo/ubuntu vs-bionic main" | sudo tee /etc/apt/sources.list.d/mono-official-vs.list  
  4. sudo apt update  
  5. sudo apt-get install monodevelop  

Now, you can build C# Apps using MonoDevelop IDE on Ubuntu 18.04.

Step 3 - Installing .NET Core 2.2

Open the CMD and run the following command

  1. wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb  
  2. sudo dpkg -i packages-microsoft-prod.deb  
  3. sudo add-apt-repository universe  
  4. sudo apt-get install apt-transport-https  
  5. sudo apt-get update  
  6. sudo apt-get install dotnet-sdk-2.2  
  7. dotnet –version  

This command will return the .NET Core 2.2 version details that confirm that the tool has been installed.

Now, you can build the first .NET Core 2.2 Web API in MonoDevelop on Ubuntu 18.04. Open MonoDevelop IDE in the Ubuntu Apps Dashboard.

Step 4 - Create .NET Core Web API in MonoDevelop

First, click and create a new Project.

Create .NET Core Web API (C#) In MonoDevelop On Ubuntu 18.04 

Now, select “ASP.NET Core Web API” and click the "Next" button.

Create .NET Core Web API (C#) In MonoDevelop On Ubuntu 18.04 

Put some names in the required fields and click "Create".

Create .NET Core Web API (C#) In MonoDevelop On Ubuntu 18.04 

You can see a .NET Core Web API tree solution.

Create .NET Core Web API (C#) In MonoDevelop On Ubuntu 18.04 

Select Program.cs and add the following code.

Create .NET Core Web API (C#) In MonoDevelop On Ubuntu 18.04 

Double-click the solution name, that will open Options window. Select Run -> Default Option and put the following port number.

Create .NET Core Web API (C#) In MonoDevelop On Ubuntu 18.04 

Done. Now, run the program and check it in a web browser. The .NET Core Web API is ready.

Create .NET Core Web API (C#) In MonoDevelop On Ubuntu 18.04
 
Create .NET Core Web API (C#) In MonoDevelop On Ubuntu 18.04 

Summary

This tutorial showed how to install and create a .NET Core Web API 2.2 in MonoDevelop on Ubuntu 18.04.


Similar Articles