An open API service indexing awesome lists of open source software.

https://github.com/castle/castle-dotnet-example

An example .NET MVC site using the Castle SDK
https://github.com/castle/castle-dotnet-example

Last synced: 8 months ago
JSON representation

An example .NET MVC site using the Castle SDK

Awesome Lists containing this project

README

          

# 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

```csharp
services.AddDbContext(options =>
options.UseInMemoryDatabase("CastleDemo")
);
```

- Visual Studio scaffolding has been used to create a Login page we can alter, as described by Microsoft [here](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity).
- We use [Microsoft.VisualStudio.Threading](https://www.nuget.org/packages/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](https://castle.io/docs/baseline), with the addition of [secure requests](https://castle.io/docs/securing_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