Question

I am developing web chat using SignalR and ASP.NET. And I want to get some fields (current account of user) from default.aspx.cs class in my Hub class. How can I do it? May be there are any workarounds?

Was it helpful?

Solution

Problem is solved. I wanted to add information about current user in my Hub class in OnDisconnect function for marking the user as offline. But program crashed after I closed browser tab with my chat. I am not sure but it is related with that program used URL for requests and now it can't do it. So I was need to save my information anywhere. I could not use non-static fields of Hub class and I tried to use aspx.cs class. But as far I know it is impossible. Problem is solved using Context.User field of Hub class. See Hub documentation of SignalR.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top