Ask or search…

Perigee With .NET Hosting

Here's the full setup guide for a Perigee Application with included API hosting, CORS, and swagger. You can download the completed result here:

1- Create an ASP.NET Core Web API project

Using Visual Studio we are going to create a new project. We want to select "ASP.NET Core Web API".

2- Configure the application as needed

When you get to configuration, feel free to override these settings as desired. An example configuration of this is shown below.

3 - Setup Program.cs

After opening Program.cs - the template created a project for us which looks like this:
We're going to add a few things to this basic setup to get it fully configured for Perigee.
  • We're going to add the ThreadRegistry instance to the builder host services.
  • We need to use Serilog.
  • Let's add CORS for cross origin.
  • Instead of running the application in synchronous mode we capture the asynchronous task handle.
  • Pass it to Perigee.

The "new" Program.cs

using Perigee;
using Serilog;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
//SwaggerGen -
//Build / configure
var app = builder.Build();
if (app.Environment.IsDevelopment()) app.UseSwagger().UseSwaggerUI();
// HTTPS/Auth/Controllers/Cors
app.UseCors(o => o.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
//Run async!
var taskRunner = app.RunAsync();
//Pass the taskRunner to Perigee initialization
PerigeeApplication.ApplicationNoInit("Hosted Perigee App", (c) => {
//Add and configure away
//Sample running config
c.AddRecurring("Running", (c, l) => { l.LogInformation("I'm running"); });
}, HostTask: taskRunner);
// TODO:
// Using the package manager console, or the Nuget GUI: install-package Perigee
// Add AppSettings.json and set the "Copy To Output Directory" in the Properties inspector to "Copy Always"

4 - Installation

We need to install Perigee as a dependency.
Either use the Nuget GUI or the Package Manager Console and type install-package Perigee

5- AppSettings.json

The AppSettings.json file is slightly different when using .NET hosting, as we want to turn off the debug level logging for Serilog and AspNetcore.
"ConnectionStrings": {
"AppSettings": {
"Perigee": { "HideConsole": false },
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"System": "Warning",
"Microsoft.AspNetCore": "Warning"
"WriteTo": [
{ "Name": "Console" }
"AllowedHosts": "*"

File / Copy Settings

Depending on the template and .NET version you selected the appsettings.json file may or may not exist. Feel free to download and drop in the one provided if it is not automatically included. As always, make sure this is set to "Copy Always" in the Property Inspector.

6- License file

Please copy your license file into the project root and set to "Copy Always"

Running the application

After clicking "Run" - You should see Swagger in the default browser, and the Perigee application console window with .NET hosting running.