Skip to content

💉Problem Initializing Session with Dependency Injection in Blazor Server Project #26

@neozhu

Description

@neozhu

Hello @alexyakunin,
I'm working on integrating the Fusion library into my Blazor Server project to enable real-time interaction. I have already implemented user login and authentication using Identity.EntityFrameworkCore. However, I'm encountering an issue when injecting the Session service into a Blazor component.

Error:
When I try to inject the Session instance using the following syntax:

@inject Session Session
...
@Session.Id

I get the following error message:

System.InvalidOperationException: Property Session is not initialized.

image

Configuration Code for Fusion Service:

 // Fusion services
 var fusion= services.AddFusion();
 fusion.AddOperationReprocessor();
 fusion.AddAuthService<InMemoryAuthService>();
 fusion.AddBlazor().AddAuthentication().AddPresenceReporter();
 fusion.AddInMemoryKeyValueStore();
 fusion.AddService<IUserSessionTracker, UserSessionTracker>();
 fusion.AddService<IOnlineUserTracker, OnlineUserTracker>();

Project Information:

Framework: Blazor Server
Identity Integration: Identity.EntityFrameworkCore is used for user login and authentication.

Additional Information:
If there are additional configurations or a different approach to session management that I should consider, I would greatly appreciate any advice on implementing this correctly.

Thank you for your assistance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions