Skip to main content
Version: 2.0.31

How to Deploy a .NET App (ASP.NET Core)

This guide shows how to run an ASP.NET Core web application (minimal API, MVC, Razor Pages or Blazor Server) on OpenPanel. The app runs in its own container with Microsoft's official .NET SDK image, and OpenPanel's web server forwards your domain to it with free SSL.

INFORMATION

.NET applications are available in OpenPanel Enterprise, and the feature must be enabled for your hosting plan.

On Linux, ASP.NET Core serves requests with its built-in Kestrel server, so you don't need IIS or a different web server: Nginx, Apache, OpenResty or LiteSpeed simply proxy the domain to the app. This works for .NET 8 and newer. Classic ASP.NET Framework 4.x apps (WebForms, MVC 5, WCF) need Windows and can't run on OpenPanel; they have to be ported to ASP.NET Core first.


Option 1: Upload the Source and Publish on the Server​

Check the port​

The .NET 8+ container images make Kestrel listen on port 8080 (ASPNETCORE_HTTP_PORTS=8080), so a default project needs no change. Don't hardcode a different URL with UseUrls() unless you also enter that port in the form.

Upload and create the app​

  1. Add the domain in OpenPanel → Domains and upload the project (the .csproj, Program.cs and the rest of the source) to the domain folder, e.g. /var/www/html/example.com/, with the File Manager or FTP. Leave out bin/ and obj/.
  2. Go to OpenPanel → Websites → Install App → Set up .NET application:
FieldValue
Domainexample.com
Port8080
Startup File/var/www/html/example.com/out/MyApp.dll (the project name, or AssemblyName if the .csproj sets one)
Versionthe .NET version your app targets, e.g. 8.0 or 10.0
Run dotnet publish✅ on
CPU / Memory1 core, 1 GB

With Run dotnet publish on, every start of the container runs dotnet publish -c Release -o out and then dotnet out/MyApp.dll. The app keeps the domain folder as its working directory, so appsettings.json and wwwroot/ next to the .csproj are found as usual.

Publishing compiles the app, so give it at least 1 GB of memory, less can get the build killed.

To deploy a new version, upload the changed files and Restart the app.


Option 2: Upload an Already Published App​

Publish on your computer or in CI:

dotnet publish -c Release -o publish

Upload the contents of publish/ to the domain folder, then create the app with the startup file /var/www/html/example.com/MyApp.dll and Run dotnet publish off. The app starts in a second, and the container needs much less memory since nothing is compiled on the server.


Option 3: Deploy from Git​

Paste the repository's https:// URL in the Git repository URL field of the install form. OpenPanel reads the .csproj at the repository root and fills in the startup file (out/<AssemblyName>.dll) for you, then fetches the latest commit and publishes it every time the container starts. Keep Run dotnet publish on.

To try it, use the example app stefanpejcic/net-helloworld:

https://github.com/stefanpejcic/net-helloworld.git

Choosing a Version​

The version list shows the released .NET versions from 8.0 up. A project built for an older target runs on a newer .NET only if it allows it, add this to the .csproj to let it roll forward:

<RollForward>Major</RollForward>

HTTPS and Forwarded Headers​

TLS ends at OpenPanel's web server, which talks to the app over plain HTTP. The container sets ASPNETCORE_FORWARDEDHEADERS_ENABLED=true, so Request.Scheme, redirects and generated links use https:// and the visitor's real IP. Remove app.UseHttpsRedirection() if it causes a redirect loop, the web server already redirects to HTTPS.


Databases​

Inside OpenPanel, databases are reached by service name - never localhost:

{
"ConnectionStrings": {
"Default": "Server=mysql;Port=3306;Database=user_myapp;User=user_myapp;Password=..."
}
}

Use mariadb for MariaDB, or Host=postgres;Database=dbname;Username=...;Password=... for PostgreSQL with Npgsql.


Managing the App​

In OpenPanel → Websites → Sites, click Manage to start, stop or restart the app, view Logs (Kestrel output and exceptions), run dotnet publish, see the .csproj packages, and change the .NET version, startup file and CPU/memory limits under Overview. After changing the version, Restart the app to switch to the new image.

More: .NET applications.


Troubleshooting​

ProblemFix
502 Bad Gateway right after startThe first start downloads the image and publishes the app, which can take a minute or two - wait and reload. If it persists, check Logs and that the Port is 8080 or whatever the app listens on.
The application '...dll' does not existThe startup file doesn't match the published dll. Check the name in out/ and the AssemblyName in the .csproj.
You must install or update .NET to run this applicationThe app targets a newer .NET than the selected version. Pick a matching version, or add <RollForward>Major</RollForward>.
Container is killed during publishNot enough memory for the build. Raise the memory limit, or publish locally and upload the output (Option 2).
Redirect loopRemove app.UseHttpsRedirection(), HTTPS is handled by the web server.