Skip to content

Clarify and update DI for SignalR hubs - #37662

Open
guardrex wants to merge 32 commits into
mainfrom
guardrex/signalr-hubs-di-remark
Open

guardrex wants to merge 32 commits into
mainfrom
guardrex/signalr-hubs-di-remark

Conversation

@guardrex

@guardrex guardrex commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Fixes #9658

I discovered this old issue (Nov, 2018) while working on the Fundamentals node for Blazor. This SignalR/DI issue should be closed out separately from Blazor work on the DI article because the Blazor work was already addressed by #36816.

I'm adding content to the existing DI section, and I'm updating the current content.

I'm taking the thrust of the lifetime comments from Ashley's remarks at #9658 (comment). The rest comes from a combo of knowledge, reference content, and AI suggestions ... and Copilot and I churned quite a bit on phrasing. I hope we came up with the right language here. 🤞🍀

Brennan, your comment here about IHubContext<T> on that issue was already addressed by some other PR since then, but it was addressed in the Create a hub section. I'm moving it down to the existing section on DI.


Internal previews

File Preview link
aspnetcore/fundamentals/dependency-injection.md Learn preview
aspnetcore/signalr/hubs.md Learn preview
aspnetcore/signalr/hubs/includes/hubs-2.1.md Learn preview
aspnetcore/signalr/hubs/includes/hubs-3-5.md Learn preview
aspnetcore/signalr/hubs/includes/hubs-6.md Learn preview
aspnetcore/signalr/hubs/includes/hubs-7.md Learn preview

Build report

This comment was marked as resolved.

@guardrex
guardrex marked this pull request as draft September 16, 2026 15:35

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

guardrex and others added 2 commits September 17, 2026 12:50
Corrected a typo in the documentation regarding the hub's constructor and database operations.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

This comment was marked as resolved.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved review comments remain, and the changes are assessed as ready for approval.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@guardrex
guardrex marked this pull request as ready for review September 17, 2026 17:27

You can specify a return type and parameters, including complex types and arrays, as you would in any C# method. SignalR handles the serialization and deserialization of complex objects and arrays in your parameters and return values.

## Inject services into a hub

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can we delete this file and the 6 and 7 versions?

@guardrex guardrex Sep 22, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes ... but it's a task for another issue because its going to take a minute to untangle the coverage and set the content and versioning into place. I opened #37729 for it. If Wade is busy, I told him that he can assign me to take care of it, and I might be able to do so by EOW.

Comment thread aspnetcore/signalr/hubs.md Outdated
Comment thread aspnetcore/signalr/hubs.md
Comment thread aspnetcore/signalr/hubs.md Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Documentation on how to inject/access DBContext or information on scoped services in SignalR

4 participants