# Deploy ASP.NET Core in one sentence.

> Deploy ASP.NET Core with a ready-made Dockerfile, or say "deploy this" in Claude Code or Codex. Preview every version; PostgreSQL in one click.

Web page: https://agentlab.cresclab.com/en/deploy/aspnet-core  
繁體中文 (Markdown): https://agentlab.cresclab.com/deploy/aspnet-core.md

ASP.NET Core deploy guide · Agent Lab Deploy

Add the Dockerfile below to your ASP.NET Core project — or tell Claude Code, Codex or Cursor "deploy this". Agent Lab builds it into a web service, gives every version a preview URL, and checks uploads for leaked keys.

[Start free](https://app.agentlab.cresclab.com/?lang=en&intent=deploy) [See the setup](https://agentlab.cresclab.com/en/deploy/aspnet-core#recipe)

An AI coding tool deploys a ASP.NET Core project to Agent Lab: it creates the project, uploads, waits for the build and reports the live URL.

Why deploy ASP.NET Core on Agent Lab

## ASP.NET Core online without running a server yourself

.NET project, built from a Dockerfile, deployed as a web service.

### A Dockerfile that fits

The Dockerfile below listens on $PORT, runs as non-root and writes only to /tmp, the rules the platform checks.

### Preview, then go live

Every upload is a new version with its own URL. Look first, then go live.

### Leaked keys caught

Uploads are checked for API keys and credentials before they can go live. Secrets go in the console, never in the code.

### PostgreSQL in one click

Create a database and connect it; the connection is written into the app's environment and the password is never shown.

Your options

## ASP.NET Core on Agent Lab, or on your own VPS

Deploying ASP.NET Core on Agent Lab compared with a self-managed VPS

| What you care about | Agent Lab Deploy | Your own VPS |
| --- | --- | --- |
| Setup | Upload with the Dockerfile below, or say one sentence | SSH, a runtime, a process manager, a reverse proxy |
| HTTPS and domains | Automatic, custom domains on paid plans | Certbot and DNS by hand |
| Before going live | Uploads checked for leaked keys | Nothing unless you set it up |
| Database | PostgreSQL in one click, connection written into the app | Install and back it up yourself |
| Cost to start | Free plan: US$0, one size-S app (sleeps when idle) | A VPS at roughly US$6–20 a month, plus your time |

Steps

## Deploy ASP.NET Core in four steps

1. ### Prepare
   Add the Dockerfile below at the top of the project and replace the placeholder names.
2. ### Upload or ask
   Drop the folder on a project's Deploy tab, push from GitHub, or ask your AI tool through Agent Lab MCP.
3. ### Build and check
   The platform builds the version and checks it for leaked keys. Enter any secrets it lists in Settings.
4. ### Preview and go live
   The first version goes live once it builds. Later ones get a preview URL; go live when you're happy.

Setup

## A ASP.NET Core Dockerfile

Replace MyApp.dll with your project's name. Data Protection keys default to the filesystem and change on restart; persist them to the database or Redis for stable cookies.

Copy

### Dockerfile

```
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY . .
RUN dotnet publish -c Release -o /out

FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /out .
# .NET 8 映像檔預設監聽 8080、以非 root 的 app 使用者執行
# .NET 8 images listen on 8080 and run as the non-root app user
USER app
EXPOSE 8080
ENTRYPOINT ["dotnet", "MyApp.dll"]
```

- `ASPNETCORE_HTTP_PORTS` 8080 by default, the same as the platform; leave it.
- `ConnectionStrings__Default` double underscores map to nested settings; put the database connection string here.

Prompt

### Or ask your AI tool

```
Read https://app.agentlab.cresclab.com/agent/deploy.md and deploy this ASP.NET Core project to Agent Lab using the Dockerfile at the top. Show me the build plan and the environment variables it needs first, tell me where to enter any secrets, and wait for my OK before it goes live.
```

FAQ

## Deploying ASP.NET Core: questions

**Do I need a Dockerfile to deploy ASP.NET Core?**

Yes. Agent Lab builds ASP.NET Core from the Dockerfile at the top of the project; the one on this page meets the platform's rules (listen on $PORT, linux/amd64, write only to /tmp). [Docs →](https://agentlab.cresclab.com/docs/en/deploy/container-app)

**Does .NET 6 or 7 work?**

Yes, with the matching sdk and aspnet images; images before .NET 8 listen on port 80, so set ASPNETCORE_URLS=http://+:8080.

**Where do API keys and other secrets go?**

In the project's Settings, under Secrets; the code reads them as environment variables. Random values such as session secrets can be generated in the console without anybody seeing them. A key found in an upload stops it before it goes live.

**Can I deploy ASP.NET Core from Claude Code or Codex?**

Yes. Connect Agent Lab MCP once (one command, sign in in the browser, no API key), then say "deploy this ASP.NET Core app". The tool creates the project, uploads, waits for the build and asks before going live. [Connect MCP →](https://agentlab.cresclab.com/en/mcp)

**Is there a free way to host ASP.NET Core?**

The Free plan is US$0: one size-S app that sleeps after 15 idle minutes, one size-S database, three static web pages, 100 build minutes and 5 GB of traffic a month, pausing at the limit instead of charging. Pro (US$29 a month before tax) keeps apps running and adds custom domains. [Pricing →](https://agentlab.cresclab.com/en/deploy#pricing)
