master student
master student

Reputation: 58

How to pass data to Signalr hub class

I have some global data that stored in session["Gdata"] so that I can access these information any time I want. However, I can't access session["Gdata"] in signalr hub class. Is there any way to access session in hub class ?

Upvotes: 1

Views: 933

Answers (1)

Ahmed Shamel
Ahmed Shamel

Reputation: 1962

You can't use session in Signalr hub class, see this link

No access to the Session information through SignalR Hub. Is my design is wrong?

There are some solutions to your problem. You can use Standard ASP.NET security to store your global information.

You can store the data you want using this code

FormsAuthentication.SetAuthCookie("string contain your data", false);

and you can retrieve your data using this code

string GlobalData = Context.User.Identity.Name;

Upvotes: 2

Related Questions