OrionGuard.SignalR
7.0.0
dotnet add package OrionGuard.SignalR --version 7.0.0
NuGet\Install-Package OrionGuard.SignalR -Version 7.0.0
<PackageReference Include="OrionGuard.SignalR" Version="7.0.0" />
<PackageVersion Include="OrionGuard.SignalR" Version="7.0.0" />
<PackageReference Include="OrionGuard.SignalR" />
paket add OrionGuard.SignalR --version 7.0.0
#r "nuget: OrionGuard.SignalR, 7.0.0"
#:package OrionGuard.SignalR@7.0.0
#addin nuget:?package=OrionGuard.SignalR&version=7.0.0
#tool nuget:?package=OrionGuard.SignalR&version=7.0.0
OrionGuard.SignalR
A hub filter that validates hub method arguments with your IValidator<T> registrations and rejects a bad invocation with a HubException, without dropping the connection.
dotnet add package OrionGuard.SignalR
using Microsoft.AspNetCore.SignalR;
using Moongazing.OrionGuard.DependencyInjection;
using Moongazing.OrionGuard.SignalR;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOrionGuardSignalR();
builder.Services.AddValidator<ChatMessage, ChatMessageValidator>();
var app = builder.Build();
app.MapHub<ChatHub>("/chat");
app.Run();
public sealed record ChatMessage(string Text);
public sealed class ChatMessageValidator : AbstractValidator<ChatMessage>
{
public ChatMessageValidator()
{
RuleFor(x => x.Text, nameof(ChatMessage.Text), p => p.NotEmpty().Length(1, 500));
}
}
public sealed class ChatHub : Hub
{
public Task Send(ChatMessage message) => Clients.All.SendAsync("receive", message);
}
A client invoking Send with an empty Text gets back a HubException whose message reads Validation failed: Text: <message>, the hub method does not run, and the connection stays open. The core OrionGuard package comes along as a dependency; SignalR itself is in the ASP.NET Core shared framework.
What the filter does
AddOrionGuardSignalR() registers OrionGuardHubFilter as a singleton, calls AddSignalR(), and adds the filter to every hub.
- For each non-null argument it runs every
IValidator<T>registered for the argument's runtime type. An argument with no registered validator is skipped. - Validators come from the hub invocation's scope (
HubInvocationContext.ServiceProvider), so a scoped validator, or one holding aDbContext, works. - They run one after another through
ValidateAsync, soRuleForAsyncrules run and two validators never touch a scopedDbContextat the same time. - Errors from all arguments are collected before anything is thrown, listed in argument order and then validator registration order, and joined into
Validation failed: <field>: <message>; <field>: <message>.
What this does not do
- The client gets one string, not structured errors. SignalR delivers the
HubExceptionmessage; there is no per-field error payload on the wire. If your UI needs to highlight fields, send the model to a validating endpoint instead, or put the structure in your own result type. - It does not find your validators. No assembly scanning; register each one with
AddValidator<T, TValidator>(). - Matching is by runtime type, across every hub. Registering
IValidator<string>means everystringargument of every hub method in the process is validated by it. Prefer a message type per hub method. - Do not add the filter twice.
AddOrionGuardSignalR()already installs it globally; addingoptions.AddFilter<OrionGuardHubFilter>()on top runs it — and your validators — a second time per invocation. - Only method arguments are validated. Values streamed from the client (
IAsyncEnumerable<T>parameters), values the hub sends to clients, and connection lifetime events are not.
Targets
net8.0, net9.0, net10.0. Uses the ASP.NET Core shared framework; no package dependencies beyond OrionGuard itself.
With the rest of OrionGuard
OrionGuard · OrionGuard.AspNetCore (the same validators for HTTP endpoints)
Documentation
License
MIT. See LICENSE.txt.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- OrionGuard (>= 7.0.0)
-
net8.0
- OrionGuard (>= 7.0.0)
-
net9.0
- OrionGuard (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 7.0.0 | 175 | 9/20/2026 |
| 6.7.0 | 143 | 7/20/2026 |
| 6.6.2 | 148 | 6/20/2026 |
| 6.6.1 | 150 | 6/20/2026 |
| 6.6.0 | 131 | 6/19/2026 |
| 6.5.30 | 139 | 6/17/2026 |
| 6.5.29 | 120 | 6/15/2026 |
| 6.5.28 | 139 | 6/15/2026 |
| 6.5.27 | 138 | 6/15/2026 |
| 6.5.26 | 145 | 6/13/2026 |
| 6.5.25 | 139 | 6/13/2026 |
| 6.5.24 | 138 | 6/12/2026 |
| 6.5.23 | 137 | 6/12/2026 |
| 6.5.22 | 125 | 6/11/2026 |
| 6.5.21 | 133 | 6/11/2026 |
| 6.5.20 | 133 | 6/11/2026 |
| 6.5.19 | 128 | 6/11/2026 |
| 6.5.18 | 134 | 6/11/2026 |
| 6.5.16 | 125 | 6/11/2026 |
| 6.5.15 | 139 | 6/11/2026 |