Skip to content

Latest commit

 

History

History
39 lines (24 loc) · 1.6 KB

README.md

File metadata and controls

39 lines (24 loc) · 1.6 KB

Castle .NET Example

This is an example of integrating Castle with a standard ASP.NET Core Razor Pages application.

Foundation

The example is almost fully from the default Visual Studio template for a Razor Pages app with Invididual user accounts for authentication.

Framework

NET Core 6.0

Template modifications

  • 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 integration

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 Ioc
  • Areas/Identity/Pages/Account/Login.cshtml.cs Castle SDK calls
  • Pages/Shared/_Layout.cshtml Client-side Castle
  • appsettings.json Your Castle API secret and App ID

Development testing

nuget add pathtonugetpackage.nupkg -source sourceDir

dotnet add package Castle.Sdk -s sourceDir