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.
<sessionState mode="StateServer" stateConnectionString="tcpip=localhost:42424" />
under the <system.web>
element and started my local ASP.NET State Service".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.
Look for any HttpHandlers or HttpModules in your web application. It's entirely possible that these are requiring session state even though your pages are not.
You are missing something. Because in ASP.NET Web Forms default page handler ( Page class ) doesn't implement "IRequiresSessionState" interface by default. I've tried your case with bulk ASP.NET website:
you can repeat same experiment easily.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With