I am getting an exception usually at night on a new project of mine. It is deployed to a hosting provider and visable to everyone.
My exception is:
Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the <system.web><httpModules> section in the application configuration.
In my web.config there is:
<pages validateRequest="false" enableSessionState="true"
enableViewStateMac="true" enableEventValidation="true"
viewStateEncryptionMode="Always">
The exception is happening while getting Session.SessionID
within one of my modules. This module is present on all pages in the application.
The application runs fine when I am here at work - but a night when I am not here this happens. I also never got this error while running application on my local dev machine. So I suspect a bot. Or possibly, hosting company shutting down services for some reason?
Is there any way to prevent this from happening? Like
if(Session.Isavailable)
or something I can add to my function in programmatically?