Room of a pleinolijf

Ask yourself this: how do I want to be remembered ?

HttpContext.Current.Session is null, but it shouldn’t be

2 Comments

Annoying issue yesterday.  I was meaning to write a dead-simple web application in .NET 4.0 that talks simultaneously to a referenced .NET 3.5 assembly, and uses an in-house .NET 4.0 framework of services (also referenced).  The goal was to test the correct operation between these different .NET version assemblies.  In most cases, that’s not even a thing to consider, but we wanted to be absolutely sure.

When calling a method of the referenced 3.5 assembly, which acts as a facade between a client and a web service, there is code that uses the HttpContext.Current.Session.  I was assuming that with my test client, being a web application, this would be all fine and dandy, but apparently not.  The HttpContext Session was null.

The solution ?  Adding

<sessionState mode="InProc" />

to the client application’s web.config, in the <system.web> section.

 

It’s not clear to me what the cause of this is.  I strongly doubt it’s default configuration behaviour, and I’m sure it has nothing to do with the code of the referenced assembly.  From what I know and have read on the subject, the session would have been instantiated by starting the application…

If you have a clue, be sure to leave it in the comments.

 

Advertisements

Author: pleinolijf

father | volleyballer | software engineer

2 thoughts on “HttpContext.Current.Session is null, but it shouldn’t be

  1. Also be sure that your ASP.NET State Service in the local services is running

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s