Another Session question

Sep 20, 2013 at 2:17 PM
Hi all, great project. I was really bummed to see WebSocket functionality required .Net 4.5 and windows 8 so tried your solution and it works pretty well. Thanks for the great stuff.

I saw a similar one asked but here is my question:

Is there a way to access HttpContext.Current object from the NewSessionConnected event? If I try to access it from my delegate function but it is null. I need to access the Session object when a new socket connection is established.
Sep 21, 2013 at 1:45 PM
No, you cannot. The web and websocket server are running in different application container.

Only one thing you can share between web and websocket is cookie.
Sep 25, 2013 at 1:44 PM
Thanks for the answer. i feared that would be the case.
So is there a best practice for this kind of situations?
My solution was to send the asp session id to the browser on page_load then send that id back on websockets' NewSessionConnected event. This way I can identify which session uses which websocket session. Obviously this solution has some security drawbacks like passing a session variable back and forth, but that variable is already sent to the client in a cookie anyway.

Any ideas?
Sep 25, 2013 at 4:24 PM
You can save some variables you want to share between ASP.NET and WebSocket into a container (a static one or other thing) other than session.