This is an example of integrating Castle with a standard ASP.NET Core Razor Pages application.
The example is almost fully from the default Visual Studio template for a Razor Pages app with Invididual user accounts for authentication.
NET Core 6.0
- The database runs in-memory
services.AddDbContext<ApplicationDbContext>(options =>
options.UseInMemoryDatabase("CastleDemo")
);
- Visual Studio scaffolding has been used to create a Login page we can alter, as described by Microsoft here.
- We use Microsoft.VisualStudio.Threading to get access to the
Forget()
extension method, which is useful for fire-and-forget calls to async methods, like Track or Authenticate in Monitor mode.
The example application applies the steps described for the Castle Baseline Integration, with the addition of secure requests. All Castle-related changes are marked with comments containing the word Castle for easy searching, and affect the following files:
Startup.cs
IocAreas/Identity/Pages/Account/Login.cshtml.cs
Castle SDK callsPages/Shared/_Layout.cshtml
Client-side Castleappsettings.json
Your Castle API secret and App ID