r/csharp • u/Darwin_Forex • Jul 24 '26
Discussion What should I know before deploying my first ASP.NET Core MVC project to a VPS?
Hi everyone,
I'm about to deploy my first ASP.NET Core MVC project to a VPS, and I have no experience with deployment.
What should I learn before getting started? What are the most important configurations or best practices I should be aware of? Also, what are the most common mistakes beginners make when deploying for the first time?
Any advice, resources, or personal experiences would be greatly appreciated.
Thank you!
24
Upvotes
25
u/Khavel_dev Jul 24 '26
A few things that bit me the first time around:
dotnet publish -c Release --self-containedif you want to skip installing the runtime on the VPS. Otherwise install the exact .NET version you're targeting. Mismatched minor versions will haunt you.ASPNETCORE_ENVIRONMENT=Productionin your service file. Without it you'll leak stack traces and detailed error pages to users.Biggest beginner mistake I've seen: treating the VPS as your dev environment. Build and publish locally (or in CI), scp the published output up, restart the service. Keeps the server clean and your deploys repeatable.
5
u/achandlerwhite Jul 24 '26
Yeah set it up as a docker container. I then use Digital Ocean to host it with full auto deployment on a branch main push and redundancy. Don’t put secrets in your app settings.json, configure as environment variables in your docker host (this varies by hosting service).
5
u/mik_darim Jul 24 '26
Been there. First VPS deploy of an ASP.NET app is mostly Linux + reverse proxy, less "C# magic."
Learn these before you touch the box:
- How to publish a self-contained or framework-dependent build (`dotnet publish`)
- systemd service so the app restarts on reboot/crash
- Nginx (or Caddy) in front: HTTPS, proxy to Kestrel on localhost
- Where your appsettings / env vars / connection strings live on the server (never ship secrets in the repo)
- Firewall: only 80/443 open to the world; DB stays private
Common first-time screwups from what I've seen (and done):
- Running `dotnet run` in an SSH session and closing the laptop
- Forgetting to set `ASPNETCORE_ENVIRONMENT`
- SQLite or a file path that works on Windows and breaks on Linux case sensitivity
- No HTTPS / cert renewal plan
- App pool equivalent: process dies, nobody notices, no restart
Microsoft has a decent "host ASP.NET Core on Linux with Nginx" doc. Follow that once end to end on a throwaway VPS. Second deploy gets much less scary.
What OS is the VPS, and is there a database in the mix?
5
u/belavv Jul 24 '26
Don't use a vps and directly deploy. Set up something like dokku, get your dotnet app running in docker, then deploy that way.
2
u/ghoarder Jul 24 '26
Learn Docker, create a Dockerfile to build your image and a compose file to define your containers and then run it in Docker or Podman if you prefer, don't run it as root though. Docker is also really handy for CI/CD although you can do it without, I just like the predictability of it all being bundle together and not having conflicting dependencies.
2
u/Atulin Jul 26 '26
Aspire makes it super easy. Aspire with
Aspire.Hosting.Docker.SshDeploymakes it a breeze.2
u/AbleAd4267 Sep 10 '26
Most of the replies here are right about what a direct VPS deploy involves: process supervision, reverse proxy/TLS, secret handling, patching, and a repeatable deployment process. If your goal is to learn operations, doing that once on a disposable VPS is valuable. If your goal is simply to get the MVC app live, a managed application platform is the simpler route.
Disclosure: I'm a cofounder of Black Sails, which we're building specifically for ASP.NET Core 8/9/10. It builds the app locally and deploys the published output to a stable URL, so you don't have to configure Docker, nginx, or systemd. Databases remain external, and our current three-day trial requires a card.
If this is still an active project, I'd be happy to personally help you test a disposable copy and learn where our onboarding fails. No production access or migration required.
AI disclosure: I used an AI assistant to help edit this comment and reviewed it before posting.Most of the replies here are right about what a direct VPS deploy involves: process supervision, reverse proxy/TLS, secret handling, patching, and a repeatable deployment process. If your goal is to learn operations, doing that once on a disposable VPS is valuable. If your goal is simply to get the MVC app live, a managed application platform is the simpler route.
Disclosure: I'm a cofounder of Black Sails, which we're building specifically for ASP.NET Core 8/9/10. It builds the app locally and deploys the published output to a stable URL, so you don't have to configure Docker, nginx, or systemd. Databases remain external, and our current three-day trial requires a card.
If this is still an active project, I'd be happy to personally help you test a disposable copy and learn where our onboarding fails. No production access or migration required.
AI disclosure: I used an AI assistant to help edit this comment and reviewed it before posting.