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
- Host: GitHub
- URL: https://github.com/castle/castle-dotnet-example
- Owner: castle
- Created: 2019-03-13T12:57:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-04-19T12:47:03.000Z (about 4 years ago)
- Last Synced: 2025-01-10T20:45:13.286Z (over 1 year ago)
- Language: C#
- Homepage:
- Size: 652 KB
- Stars: 0
- Watchers: 8
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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