All manual sections

Documentation.NET applications (ASP.NET Core)

.NET applications (ASP.NET Core)

A site can be an ASP.NET Core application (.NET 8 or .NET 10, the LTS versions): APIs, MVC sites, Razor Pages, Blazor Server. It is set up on the site page, Node.js / Python / .NET tab, choosing .NET. No SQL Server is needed: applications use the server's MariaDB or PostgreSQL.

Runtimes

In Server › .NET the administrator sees the installed versions and installs, with one click, the ASP.NET Core runtime (it includes the .NET runtime) or the SDK. They come from Microsoft's official builds, with the SHA-512 checksum verified, and versions sit side by side. The runtime also installs itself the first time a site picks that version. The SDK (about 200 MB) is only needed to build from source on the server.

Creating it

  1. Publish the application: dotnet publish -c Release -o publish on your computer or in your CI, and upload the folder to the site home (SFTP), for example to app/publish/. Or give a Git repository with the project: if the SDK is installed the panel builds it by itself.
  2. In the tab choose .NET, the version the app is built for and the folder (for example app).
  3. Entry point: empty, the panel uses the published .dll it finds in publish/ or in the folder (the one with its .runtimeconfig.json); or write the path (publish/MyApp.dll) or a full command.
  4. Start the application. With the SDK installed and an empty folder the panel writes a small example and builds it, so the site answers right away.

If the app is built for another .NET version the panel says so before starting it.

Port, nginx and headers

The panel assigns a port on 127.0.0.1 and sets ASPNETCORE_URLS: the app must not choose a port or an address. nginx is the reverse proxy, WebSockets included (SignalR, Blazor Server). The panel also sets ASPNETCORE_FORWARDEDHEADERS_ENABLED=true: ASP.NET Core reads X-Forwarded-For and X-Forwarded-Proto and the app sees the visitor's address and https. If your code calls app.UseForwardedHeaders(), configure it with ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto.

ASPNETCORE_ENVIRONMENT is Production: to change it add the variable in Environment variables.

Databases with Entity Framework Core

Create the database in the Databases section and put the connection string in the environment variables (the double underscore becomes : in .NET configuration):

  • MariaDB (Pomelo.EntityFrameworkCore.MySql): ConnectionStrings__Default=Server=localhost;Database=shop;User=shop_u;Password=…
  • PostgreSQL (Npgsql.EntityFrameworkCore.PostgreSQL): ConnectionStrings__Default=Host=localhost;Database=shop;Username=shop_u;Password=…

Deploy from Git and management

As for Node.js and Python: the site's deploy key, the branch, Deploy fetches the new commit, runs dotnet publish into publish/ when there is a project and the SDK, restarts and checks that it answers. If the build fails, the version running stays the previous one.

Start, stop, restart, logs, memory and CPU work as for the other applications: the service runs as the site user, within its account's limits (Isolation and limits module) and with the same system protection.

Good to know

  • Move account also carries .NET applications (and Node.js and Python ones): on the destination server they start again after the files are copied, installing the runtime if missing.
  • Migration from Plesk or cPanel copies the files but doesn't start an ASP.NET Core application found in the site by itself: the report points it out, and you set it up from this tab.
  • The classic .NET Framework (ASP.NET 4.x, Web Forms) doesn't run on Linux: .NET 8 or later is needed.