---
title: "Bring an existing ASP.NET application"
canonical: https://isoplane.dev/docs/how-to/onboard-an-application
---

# Bring an existing ASP.NET application

An Isoplane application keeps its `Program.cs`. Isoplane supplies the server
transport; your application does not open a listener.

Keep an ordinary .NET project for code that also runs elsewhere, and reference it
from the Isoplane application project. Libraries still need to support the
sandbox's capabilities.

## Create the application project

Follow [the Quickstart's creation step](https://isoplane.dev/docs/quickstart#3-create-an-application) to make a `MyApi`
project next to your existing code. This supplies the matching SDK and launch
settings. Move your startup code into its `Program.cs`. If your application logic
is already in a separate library, add an ordinary project reference to that
library instead of copying its code.

Keep the existing project available while porting. Build and run a small route
first, then add the remaining services and routes and their integration tests.

## Adapt `Program.cs`

Two lines differ from an ordinary ASP.NET application:

```csharp
using Isoplane.AspNetCore;

var builder = IsoplaneHosting.CreateBuilder(args);
// Register application services here.

var app = builder.Build();
app.MapGet("/", () => "Hello from MyApi");

await app.RunAsync();
```

- `IsoplaneHosting.CreateBuilder(args)` replaces `WebApplication.CreateBuilder(args)`.
- The file ends with `await app.RunAsync()`. The synchronous `app.Run()` blocks
  until shutdown, which a sandboxed application cannot do. The editor marks the
  call as the error `ISOPLANE1020` and offers a quick fix that replaces it with
  `await app.RunAsync()`, making an explicit `void Main` asynchronous when there
  is one. A `RunAsync` whose task is discarded or blocked on is `ISOPLANE1021`,
  with the same fix.

Everything between stays as it was: service registrations before
`builder.Build()`, middleware and endpoints after it.

Isoplane runs `Program.cs` up to `RunAsync` during template preparation.
Preparation may retry; reusing a prepared template runs no initialization.
Every instance starts from the captured result. Settings, including
connection strings, are available while it runs. Two things do not carry over
into an instance: an open connection, so close any that start-up opens, and
uniqueness, so create a value that must differ between instances when an instance
starts. See [the application lifecycle](https://isoplane.dev/docs/concepts/application-lifecycle).

## Configuration

`IsoplaneHosting.CreateBuilder` reads `appsettings.json`, then
`appsettings.{Environment}.json`, then the settings the platform supplies. It does
not read your machine's environment variables. See
[local development settings](https://isoplane.dev/docs/how-to/local-settings) for how to supply settings and
choose the environment while developing.

## Check application assumptions

Go through this list once for an existing application. Each item says what to
look for, how to find it, and what to do about it. An AI coding agent can work
through it too, once `isoplane skills install` has given it a skill that links
to these pages. [Work with an AI coding agent](https://isoplane.dev/docs/how-to/work-with-an-ai-coding-agent)
describes that command.

- **Blocking calls.** A synchronous wait such as `.Result`, `.Wait()`,
  `Thread.Sleep` or a synchronous database call throws in the sandbox. Build
  with the analyzer's dependency inspection on and fix each `ISOPLANE1003`.
  [Find and fix blocking calls](https://isoplane.dev/docs/how-to/find-and-fix-blocking-calls) walks through
  it.
- **Threads.** Starting a thread throws, and the analyzer reports it as
  `ISOPLANE1002`. Rewrite the work as async code that the request awaits. See
  [one thread per instance](https://isoplane.dev/docs/concepts/dotnet-runtime-differences#one-thread-per-instance).
- **Long computations.** A method that computes for a long time without
  awaiting stalls its instance and can't be cancelled. Split it up as
  [running time](https://isoplane.dev/docs/concepts/resource-limits#running-time) describes.
- **Continuous and scheduled work.** A `BackgroundService` loop, a queue
  consumer or a job scheduler runs only while its instance exists and stops
  silently when the instance goes. Search for `BackgroundService`,
  `IHostedService` and scheduling packages. Drive the work from an endpoint
  instead, as [Run work on a schedule](https://isoplane.dev/docs/how-to/run-work-on-a-schedule) shows. See
  [background work](https://isoplane.dev/docs/concepts/dotnet-runtime-differences#background-work).
- **WebSockets and HTTP/2.** Requests arrive as HTTP/1.1 without trailers,
  which rules out gRPC over HTTP/2. WebSockets are currently unavailable.
  SignalR and Blazor Server interactivity need sticky sessions, which Isoplane
  does not keep, so they are
  [currently unsupported](https://isoplane.dev/docs/concepts/library-compatibility#signalr).
  gRPC-Web, server-sent
  events and statically rendered Blazor pages work. See
  [incoming requests](https://isoplane.dev/docs/concepts/dotnet-runtime-differences#incoming-requests)
  and [SignalR and Blazor Server](https://isoplane.dev/docs/concepts/library-compatibility#signalr).
- **Data Protection keys.** Antiforgery tokens, the TempData cookie and
  authentication cookies need the key that protected them. By default a fresh
  preparation may generate a different key. The SDK can derive keys from
  settings during preparation or reload them from an external store at each
  instance start. Keep earlier unrevoked keys while their data must remain readable.
  [Keep the keys across builds](https://isoplane.dev/docs/how-to/keep-data-protection-keys). The
  [`isoplane-webapp`](https://isoplane.dev/docs/reference/project-templates#isoplane-webapp)
  template is set up this way.
- **MCP servers.** A server built with `ModelContextProtocol.AspNetCore` works
  over Streamable HTTP in its stateless mode. With session tracking on, the
  application starts, but a request that reaches an instance other than the
  one holding its session fails with 404 `Session not found`. The
  [`isoplane-mcpserver`](https://isoplane.dev/docs/reference/project-templates#isoplane-mcpserver)
  template is such a server.
- **Durable state.** Static fields, `IMemoryCache` and in-memory session
  state belong to one instance and can vanish at any time. Keep anything that
  must last in a database or another external service. See
  [instance state](https://isoplane.dev/docs/concepts/dotnet-runtime-differences#instance-state).
- **Database connections.** Every instance pools connections on its own, so
  a pool size in the application caps nothing overall, and the pool goes when
  its instance does. Cap connections with your provider's pooler, such as
  PgBouncer or a pooled endpoint, and open a connection per request.
  [Connect to PostgreSQL](https://isoplane.dev/docs/how-to/connect-postgresql) shows this, with the
  driver's own pooling off.
- **Files.** The file system is read-only. Files in `wwwroot` are part of the
  application package, so serve them with `app.MapStaticAssets()` or
  `app.UseStaticFiles()`. For uploads and files the application generates, see
  [Handle uploads and generated files](https://isoplane.dev/docs/how-to/handle-uploads-and-generated-files).
- **Native libraries.** A NuGet package that ships a native binary fails on
  the code path that calls it. Switch on `IsoplaneAnalyzeDependencies` and
  `IsoplaneWarnOnNativeImports` to have the build list such declarations in
  packages, as
  [Control compatibility warnings](https://isoplane.dev/docs/how-to/run-and-rebuild#control-compatibility-warnings)
  shows. See
  [native libraries](https://isoplane.dev/docs/concepts/dotnet-runtime-differences#native-libraries).
- **Framework assemblies.** A package that depends on an older version of an
  assembly ASP.NET Core provides gets the framework's copy, as in an ordinary
  ASP.NET Core project. Nothing to do.

[How .NET differs on Isoplane](https://isoplane.dev/docs/concepts/dotnet-runtime-differences) covers
everything else that differs from a server process, and
[library compatibility](https://isoplane.dev/docs/concepts/library-compatibility) lists the packages
and framework features known not to work, with what to use in their place.
