When Session Objects Get Created With No Session Variables


I thought about calling this  Session Object Madness, but it really isn’t that crazy once you think through what’s happening.

Here’s the issue.  I have a client who does work for another client who is hosting their sites at IBM.

I’m told that IBM will not enable any session servers so none of the sites can include session objects.  And that’s where the fun begins.

Now I won’t go on with my normal rant about how this is just insane and how it is costing the client more for us to write code around this than if they moved the operation someplace else.  But here’s the issue.  We wanted to  add a Global.asax file to the site so that we could process errors and redirect to an error  page.  When we put this on our staging server that is half set up for a SQL session server, we started getting errors because the site was trying to connect to the session server but didn’t have a database to connect to.

What was curious was that we weren’t creating any session objects in any of the code, so the call to the database should never have happened.  Then I remembered, the Global.asax file has event handlers for SessionStart and SessionEnd.

Once we took the two event handlers out, the code started working again.

Note to self: session objects also get created when they need to attach to an event handler.

Other places talking about ASP.NET Session Objects

Coupling ASP.NET Session State With Forms Authentication – Paulo … – The session ID manager will return this session ID when queried by the session state HTTP module: public class SessionIdManager : global::System.Web.SessionState.ISessionIDManager { #region ISessionIDManager Members public string …

Difference between ASP.NET Sessions, Application variables and … – When developers start with ASP.NET Web Forms the question I always get is; where is the best place to store user information, the application variable, the session state, cookies, database or the cache objects? …

Session Time Out Tricks : Misfit Geek – I WANT TO IMPLEMENT SENDING SMS THROUGH ASP.NET. ASHOKTANU — March 1, 2010 4:23 PM. Jone avatar. >> we could implement an AJAX service method and query the server as to whether or not the REAL .NET session has expired …

BCA: ASP.NET 2.0 Session State Partitioning – SqlSessionStateStore supports a key scalability feature of ASP.NET 2.0 known as session state partitioning. By default, all sessions for all applications are stored in a single SQL Server database. However, developers can implement …

Like this Article? Subscribe to get every article sent to your email.

Related Post

  • Storing a DataRow into a Session (server) variableStoring a DataRow into a Session (server) variable I recently ran into a situation where I needed to store a DataRow object, which is not serializable, into a Session variable using the Session Server.  As I mentioned yesterday, all […]
  • The case of the disappearing session variablesThe case of the disappearing session variables Way back in ASP.NET version 1.1, I wrote one of my first asp.net web sites for a client that depended pretty heavily on session variables.  Without getting into the arguments about the […]
  • Multi-Step Processing in ASP.NETMulti-Step Processing in ASP.NET I received the following question a few days ago but I’ve been so busy with billable work that I just haven’t had a chance to answer it until now.  Actually, I’m still busy, but I […]
  • Response.Redirect() executes too soon on the Server.Response.Redirect() executes too soon on the Server. I've seen this question a couple of times in various situations. The first involves Javascript and the second involves server side code. Both are caused by a misunderstanding of what […]
  • Modifying Copies of a Session ObjectModifying Copies of a Session Object This morning I woke up to the following question in my inbox: I am storing an object into session. Then in one of my functions I am copying that session object into a local object and […]

About Dave Bush

Dave Bush is a Full Stack ASP.NET developer. His commitment to quality through test driven development, vast knowledge of C#, HTML, CSS and JavaScript as well as his ability to mentor younger programmers and his passion for Agile/Scrum as defined by the Agile Manifesto and the Scrum Alliance will certainly be an asset to your organization.

One Pingback/Trackback

  • Ivan Hanakaze

    I think that you should use InProc session mode if you cant store session objects into the server, unless you need permanent sessions, InProc works just fine, I guess.

    • Dave

      Yes, of course. But if you aren’t using session objects at all and don’t want the memory set aside for them because you aren’t, you need to make sure you don’t have any event handlers attached to the session object. That’s the point of the post. You can read this post for why you don’t want to use InProc sessions.

  • Pingback: Dew Drop – March 6, 2010 | Alvin Ashcraft's Morning Dew