Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9208183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:33:44+00:00 2026-06-18T00:33:44+00:00

To set the right context, let me explain the problem. Till RC1, we used

  • 0

To set the right context, let me explain the problem. Till RC1, we used to implement GenerateConnectionIdPrefix() to prefix user Id to the connection Id. Then we could retrieve user id from the connection string anytime we need.

With RC2, we now cannot inherit IConnectionIdPrefixGenerator & implement GenerateConnectionIdPrefix anymore. So I was wondering what are other avenues available to set any property on the hub with our data, that persists throughout the lifetime of the connection.

Going through documentation, I realized setting query strings is one way, but that would mean we need to set it for every call. Setting a round trip state might be another option, but it looks like even that is persistent for a single round-trip and not entire lifetime.

So my end goal is set to property once at start on SignalR connection that can be used throughout the connection lifetime.

If there is nothing available now, are there any plans to add support to achieve something similar in next version?

[Update]
As suggested below, I tried to set a state Clients.Caller.Userid in the OnConnected method, then tried to access it in the subsequent call, I found that its null. Both calls are from same connection Id.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:33:45+00:00Added an answer on June 18, 2026 at 12:33 am

    Look at the “Round-tripping state between client and server” section on https://github.com/SignalR/SignalR/wiki/Hubs.

    Basically you can read and write from dynamic properties on Clients.Caller in Hub methods such as OnConnected or anything invoked by a client. Ex:

    using System;
    using System.Threading.Tasks;
    using Microsoft.AspNet.SignalR;
    
    namespace StateDemo
    {
        public class MyHub : Hub
        {
            public override Task OnConnected()
            {
                Clients.Caller.UserId = Context.User.Identity.Name;
                Clients.Caller.initialized();
                return base.OnConnected();
            }
    
            public void Send(string data)
            {
                // Access the id property set from the client.
                string id = Clients.Caller.UserId;
    
                // ...
            }
        }
    }
    

    State that is stored this way will be persisted for the lifetime of the connection.

    If you want to learn how to access this state using the SignalR JS client look at the “Round-tripping state” section of https://github.com/SignalR/SignalR/wiki/SignalR-JS-Client-Hubs.

    There are other ways to keep track of users without IConnectionIdPrefixGenerator discussed in the following SO answer: SignalR 1.0 beta connection factory

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement sherlock actionbar but i can't set the right theme in
I am having problem to set label at right corner in ToolBar . Hear
Let me try it: If I don't set this, then the default value is
How can I create custom variable in helper.php file set it right here and
tesseract-android-tools-test (test project to ensure everything is set up right) works. i got my
right now its set up to write to a file, but I want it
My function right now is set to animate a pop up window on mouse
Right now I'm trying to set the default audio device on Windows 7 programmatically,
All right so I tried using the button set. So fair, I have been
Right now I have a set of if and elseif to set the height

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.