Skip to content

Instantly share code, notes, and snippets.

@davidfowl
Last active December 29, 2016 09:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidfowl/4692934 to your computer and use it in GitHub Desktop.
Save davidfowl/4692934 to your computer and use it in GitHub Desktop.
Using readonly sessions with SignalR

Session will not work with ASP.NET's websocket implementation. As a result I've deleted the code.

@ChrisTorng
Copy link

I have tried these code, with a really simple sample, but always get Session == null.
I have tried with HttpContext.Current.Session, even comment out SetSessionStateBehavior, the results are all the same.
Are there anything I should check?

@europhreak
Copy link

I would like to do the same however in my hub => Task OnConnected I don't have "Reqest" method?? I'm using signalR vjquery.signalR-1.0.0-alpha2.
??

@davidfowl
Copy link
Author

@europhreak try updating

@salvitch
Copy link

salvitch commented May 3, 2013

This did the trick for me, Thank you so much!

Copy link

ghost commented May 16, 2013

Does this gist also apply when websockets is used as the transport? What I see is that the hub method is called before the Application_BeginRequest method is called or Application_BeginRequest is not called at all. (I am using SignalR version 1.1.0)
Which Application events are called when a SignalR request is received?

@davidfowl
Copy link
Author

Sorry guys, session is busted with websockets in ASP.NET and SignalR 2.0 won't support session at all.

@mohitsharmaniit11
Copy link

Does it not even support in Long Pooling as well? In SignalR 1.1.4 does it work? If it work please add back the code

@nilangjoshi
Copy link

Does this mean Session-state is always read only with SignalR -- New Version 2.0???

We are getting long running calls on Azure which is reported with the New relic.Upon Detail Check we are getting -- "System.Web.HttpApplication.BeginRequest()" is taking longer time in Poll/Connect/Reconnect Calls."System.Web.HttpApplication.BeginRequest()" takes longer time only when sessionstate in not marked either disable or readonly in the Controller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment