Published on

Host C# apps for free!

How to host .NET Core applications for free?

Do you ever fancy the Javascript trend where everything is so simple? You can deploy a node.js app almost instantly with platforms like Vercel and have CI/CD come along without any configuration.

Well i am here to lift you up because there is a way to deploy a .NET Core application the same way. And the best part? You can host it for free! (As long you don't make money out of it).

It's a perfect way to showcase your apps, make POCs and try new things without paying a dime.

Let's dive in and let me show you how.

I want to clarify that i am not sponsored by Heroku or Vercel (sadly)..

So what is Heroku? πŸ€“

Heroku is a cloud service platform whose popularity has grown in recent years. Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly. Heroku is so easy to use that it’s a top choice for many development projects.

In other words it is a PaaS solution that helps developers deploy apps quickly. It does so by connecting to the git provider you use and deploying the application each time you sync the main branch.


The bad and the good news πŸ‘ŽπŸ‘

The bad news is that heroku (at the time of writing) only supports the following languages:

  • Node.js
  • Ruby
  • Python
  • Java
  • PHP
  • Go
  • Scala
  • Clojure

But don't worry! The good news is that a third-party buildpack exist that can provide what we need. To be able to build C# code!

Buildpacks automate the build processes for your preferred languages and frameworks.

Step by step process πŸ‘€

So let me show you how you would go about doing that for a C# app. In this tutorial i will host a simple Asp.NET Core Web API, but keep in mind that you can do the same for any .NET Core app.

The steps are:

  1. Create your .NET app.
  2. Add it to a GitHub repository. In my case i created a repo named "TestHeroku"
  3. Create an account in Heroku.

After logging in you should see the following screen:

Heroku Dashboard
  1. Click on "Create new project".
  2. Select how you want to name your app and the closest location to you.

In my case "martins-app-name" (naming done right 😐) and the Europe region.

Naming your app
  1. Click on "Create app".
  2. In the deployment method section, select "Github".
  3. In the Connect to github section, type the name of your repository and click search. Click on connect after it finds your repo.
Connecting Git
  1. Click on "Enable automatic deploys". This is the continuous delivery feature. Meaning that each time you do a 'git sync' the app will be automatically redeployed with the latest changes.
Automatic Deploys
  1. Click on "Add buildpack" in the buildpacks section under the Settings tab.
Adding BuildPack
  1. https://github.com/jincod/dotnetcore-buildpack

C# buildpack URL
  1. Go back to the deploy tab.
  2. In the manual deploy section click on "Deploy Branch.
Manual deploy
  1. You are done! You should see the application building in the "Activity" tab. So wait for a couple minutes and your app will be up and running!
See building of app in activities

Lets test the app πŸ”₯

We are now ready! We can send an http GET request and get a response by opening a postman client and typing the url of the app and the endpoint of our API. You can find the base URL in the settings in the domain section.

Testing with postman

What now? πŸ’₯

Now that we are up and running, there is a ton of possibilities ahead! We can add a purchased domain. We can create other branches to steadily add new features to our app. Each time we want to deploy we only have to sync the branch to our main branch!