DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

Strange Exceptions

Sort:
You are not authorized to post a reply.





Growing Member





    DNN 9.7.2 

    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 <configuration>\<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?






    Veteran Member





      That's an interesting issue. Depending on the website, there can be all kinds of odd things that happen overnight. One thing that seems to help with this for me is to keep the website behind a WAF of some kind. Popular options include CloudFlare and Imperva. This will help protect your website from bots in general, especially if you opt for a paid plan.

      An extra step (beyond site-specific configuration options) that we always block any country that is not meant to use the website. This actually has a pretty good impact on things, despite it being easy to side-step that. I guess most bots don't try to get around that. :)





      Growing Member





        Thank you for reply,

        How in the world do you block an entire country - that is a good idea.  

        I just have a dedicated server running windows server 2019 with plesk - I know you can block per ip, but that would be allot of ips.  Especially Russia and China - which I would just love to block.






        Veteran Member





          If you switch to using a WAF, then it's as simple as setting a firewall rule.  CloudFlare supports this scenario in its free plan (see the example screenshot below). 😊 

          When you're ready, you can add it to CloudFlare easily by copying and pasting the shortcode for it below.  

          (ip.geoip.country in {"AU" "AT" "BE" "BZ" "CA" "DK" "FI" "FR" "DE" "GL" "GU" "GR" "HU" "IS" "IE" "IM" "IT" "JP" "KR" "MX" "NL" "NZ" "NO" "PR" "ES" "SE" "CH" "UA" "GB" "US"})

          You are not authorized to post a reply.

          These Forums are dedicated to the discussion of DNN Platform.

          For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

          1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
          2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
          3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
          4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
          5. No Flaming or Trolling.
          6. No Profanity, Racism, or Prejudice.
          7. Site Moderators have the final word on approving / removing a thread or post or comment.
          8. English language posting only, please.

          Would you like to help us?

          Awesome! Simply post in the forums using the link below and we'll get you started.

          Get Involved