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
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
.
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.
Last updated