Our website uses our own custom-built session state management separate from ASP.NET Session State. But because a handful of special pages use SQL Server Reporting Services, we also need to enable ASP.NET Session State. Since we are in a load-balanced environment, we enabled the ASP.NET State Server (aspnet_state.exe or "Out-of-process Mode") on a separate backend machine.
Today I noticed that when we temporarily brought down the machine running the State Service in our Dev environment, the Dev website stopped working ("Unable to make the session state request to the session state server.") This despite having EnableSessionState="False" on the page being loaded.
Why would ASP.NET need to connect to the State Service when serving a request for a page that does not use Session State? This seems to happen even if the page does not use a Master Page, Base Page, or any User Controls. I searched through all our code-behind to ensure that we never programmatically re-enable Session State or attempt to access it.
--- EDIT AFTER MORE TROUBLESHOOTING ---
As suggested by a user below, I tried creating a web site from scratch to retest this without any complications from httpHandlers, httpModules, or other custom logic.
- I used Visual Studio 2008 to create a new "ASP.NET Web Site" using VB.NET.
- I ran the site through VS, allowing it to enable debug mode and generate a standard web.config file.
- I added
<sessionState mode="StateServer" stateConnectionString="tcpip=localhost:42424" />
under the<system.web>
element and started my local ASP.NET State Service". - I changed the Default.aspx page's EnableSessionState to False and reloaded the page = OK.
- I stopped the ASP.NET State Service and reloaded the page = "Unable to make the session state request to the session state server."
At this point I was puzzled because other users claimed that they had tried something similar and did not experience the same issue. So I wondered if it had anything to do with using VB.NET (silly though that sounds.) More people use C# for ASP.NET, so I redid my test above with a C# web site, and lo and behold, no exception when accessing the page! I only got an exception if I set EnableSessionState to True and actually accessed the Session collection in code.
This proves that VB.NET sites in ASP.NET behave slightly differently in that they access session state on each page, even if the page does not need to. Unfortunately this doesn't answer my original question: Why?
I am going to cross-post this to the official ASP.NET forums and see if any gurus there can shed some light.