Solved

Why is my HTTPContext.Current.Session null when using SignalR 2.x libraries in our ASP .Net MVC application?

Posted on 2014-02-25
2
4,193 Views
Last Modified: 2014-03-14
Hi:

I'm attempting to migrate our ASP.Net MVC application from using Signal R1.x tgo SignalR 2.x.  I just found issue which will certainly cause us problems in our quest to move forward.

Our web application is MVC based and makes heavy use of the HttpContext.Current.Session variable.
When running with SignalR 1.x, everything is fine and dandy with Session.

When we upgraded to SignalR 2.x, Session was suddenly null.

I did a little googling and found the following links regarding the issue:
http://stackoverflow.com/questions/20881591/httpcontext-current-session-is-nul-in-signalr-need-alternate-to-session-state

Further investigation revealed the following tidbit of information:
http://www.asp.net/signalr/overview/signalr-20/troubleshooting-and-debugging/troubleshooting

HTTPContext.Current.Session is null
This behavior is by design. SignalR does not support the ASP.NET session state, since enabling the session state would break duplex messaging.

Open in new window


I would imagine that this will break a great many ASP .Net MVC based applications.
Is there any workaround for this?

Is this truly by design, or is it a result of using oWin::>Startup::Configuration(){app.MapSignalR();} to initiate signalR in 2.x?

If possible, I’d like to figure this out and if the solution is not so painful, they will still consider moving to 2.x.

Thoughts?

Thanks in advance for your time,
JohnB
0
Comment
Question by:jxbma
  • 2
2 Comments
 
LVL 1

Accepted Solution

by:
jxbma earned 0 total points
Comment Utility
OK. After doing a bunch of research, the reason my context is null given the difference between the in the architecture between 1.x and 2.x SignalR libraries.

Basically, in 2.x, the startup/initialization sequence is different than 1.x SignalR initializes before HTTP Context has been initialized. Therefore the context is null/ not accessible.

JB
0
 
LVL 1

Author Closing Comment

by:jxbma
Comment Utility
Researched the issue myself and found the answers I was looking for.

JB
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now