Skip to content

An example .NET MVC site using the Castle SDK

Notifications You must be signed in to change notification settings

castle/castle-dotnet-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

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

About

An example .NET MVC site using the Castle SDK

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published