Room of a pleinolijf

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


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

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.


Leave a comment

When IIS and ASP.NET don’t get along

I found an interesting article while looking for a solution to an error I got on a form. The form contains several server-side validator controls, and when I would load the form, an error pops up telling me it can’t find the WebUIValidation.js file.
I’m familiar with this error. I’ve seen colleagues get it, but never experienced it myself. But recently, I got a new laptop, installed all the necessary software, and I even worked on a project, without having that same error. Only today, when I switched to another project, the error pops up out of nowhere.

This page [ ] clearly explains what and how, and provides info about the .NET utility aspnet_regiis.exe, and its different uses. A must-know.

TechnoratiTechnorati Tags: , , ,