title: Access SignalR Hub Context.Items from an singleton service in ASP.NET Core
body: <p>I am attempting to paginate my signalR broadcast of a large table so that each subscribed group has a &quot;current page&quot; that the users see. I want the state of the page number to live in the Hub's Context.Items dictionary.</p>
  <p>In my hub I set page number like this:</p>
  <pre><code>public class OnlineBotsHub : Hub
  {
      public async Task JoinGroup(string num)
      {
          await Groups.AddToGroupAsync(Context.ConnectionId, num);
          await Clients.Group(num).SendAsync(&quot;AddedToGroup&quot;, &quot;added to group number: &quot; + num);
      }
  
      public void Pagination(string pageNum)
      {
          Context.Items.Add(&quot;page&quot;, pageNum);
      }
  }
  </code></pre>
  <p>Currently I inject my hub into the singleton service like this:</p>
  <pre><code>private readonly IHubContext&lt;OnlineBotsHub&gt; _hub;
  public OnlineBotService(IHubContext&lt;OnlineBotsHub&gt; hub)
  {
      _hub = hub;
  }
  </code></pre>
  <p>But I cannot seem to access the Hub's Context.Items property with this reference.
  I would like to use this value in a singleton service like this:</p>
  <pre><code>Context.Items.TryGetValue(&quot;page&quot;, out object currentPage);
  var returnList = PagedList&lt;T&gt;.ToPagedList(addBots.OrderBy(x =&gt; x.RowId), currentPage, 100);
  </code></pre>
  <p>Am I able to access the Hub's Context.Items dictionary from this other class somehow?</p>