Skip to content
For agents
Browse guides

ASP.NET Core

Prepare and deploy a C# / .NET HTTP app from source or a container image.

Open Markdown

Deploy an ASP.NET Core app from source. Smolcloud restores your NuGet packages and publishes the app for Linux.

Prepare your app

Make the server listen on 0.0.0.0 and the port in PORT:

Code
var app = WebApplication.CreateBuilder(args).Build();
app.MapGet("/", () => "Hello from Smolcloud");
app.Run("http://0.0.0.0:" + Environment.GetEnvironmentVariable("PORT"));

Add a health route that returns 200 and set it as the app's health path in Configuration. Listen on plain HTTP: Smolcloud provides HTTPS in front of your app, so don't redirect to HTTPS inside the app.

Deploy source

Include the .csproj file. To pin the .NET SDK version, add a global.json, and make sure your target framework works with that SDK. Public packages are downloaded from NuGet.

Create the app to get its ID, then deploy the source folder:

Shell
smolcloud deploy APP_ID ./my-app

If the folder has a Dockerfile, Smolcloud uses that instead. Automatic builds lists what a build can download and where to see the commands it chose.

Set the port and health path in the app's Configuration. deploy waits until the app is live and prints its address. Open it and try a real page, not only the health path. If you need a private package registry, build an image in your own CI and deploy that.

Limits

  • The app runs as user 10001:10001, not root, and can't write to its own filesystem.
  • Builds can't reach private package registries or other download sites.
  • Keep data in PostgreSQL, a bucket or a disk; anything else is lost on the next deploy.