Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Session problem

Session problem

Scheduled Pinned Locked Moved C#
visual-studiohelpcsharpdata-structuresdebugging
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Snowjim
    wrote on last edited by
    #1

    Hey! I am running Visual Studio 2005 professional. I am now working on a webproject where i need to use sessions I store sessions like this Session.Timeout = 30; Session.Add("profileId", profileId); and im getting the sessions by this code: try { if (Session["profileId"] != null) { mUserId = int.Parse(Session["profileId"].ToString()); postMessage.Controls.Add(LoadControl("~/common/uc/loginBox.ascx")); } } catch (Exception ex) { throw (ex); } The problem is when we reach the if i get a error: 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 \\ section in the application configuration. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: 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 \\ section in the application configuration. Any ide what i need to do? i havent had this problem before? Best Regards Jimmy

    S G S 3 Replies Last reply
    0
    • S Snowjim

      Hey! I am running Visual Studio 2005 professional. I am now working on a webproject where i need to use sessions I store sessions like this Session.Timeout = 30; Session.Add("profileId", profileId); and im getting the sessions by this code: try { if (Session["profileId"] != null) { mUserId = int.Parse(Session["profileId"].ToString()); postMessage.Controls.Add(LoadControl("~/common/uc/loginBox.ascx")); } } catch (Exception ex) { throw (ex); } The problem is when we reach the if i get a error: 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 \\ section in the application configuration. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: 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 \\ section in the application configuration. Any ide what i need to do? i havent had this problem before? Best Regards Jimmy

      S Offline
      S Offline
      siva pinnaka
      wrote on last edited by
      #2

      by default enablesessionstate is true. Incase it is false,you can enable sessionstate at page level by setting enablesessionstate of page directive to true. Thanks

      1 Reply Last reply
      0
      • S Snowjim

        Hey! I am running Visual Studio 2005 professional. I am now working on a webproject where i need to use sessions I store sessions like this Session.Timeout = 30; Session.Add("profileId", profileId); and im getting the sessions by this code: try { if (Session["profileId"] != null) { mUserId = int.Parse(Session["profileId"].ToString()); postMessage.Controls.Add(LoadControl("~/common/uc/loginBox.ascx")); } } catch (Exception ex) { throw (ex); } The problem is when we reach the if i get a error: 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 \\ section in the application configuration. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: 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 \\ section in the application configuration. Any ide what i need to do? i havent had this problem before? Best Regards Jimmy

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        You have probably disabled session state for the page. Check the properties for the page. By the way, why are you taking the value from the session variable, converting it to a string, and then back to an integer? Isn't the value you put in the session variable an integer? Just check if the data type is correct and then cast it. --- b { font-weight: normal; }

        S 1 Reply Last reply
        0
        • G Guffa

          You have probably disabled session state for the page. Check the properties for the page. By the way, why are you taking the value from the session variable, converting it to a string, and then back to an integer? Isn't the value you put in the session variable an integer? Just check if the data type is correct and then cast it. --- b { font-weight: normal; }

          S Offline
          S Offline
          Snowjim
          wrote on last edited by
          #4

          Hey My page header looks like this <%@ Page Language="C#" AutoEventWireup="true" CodeFile="communityReplys.aspx.cs" Inherits="community_communityReplys" %> But i am inherting from a base class that are in hearting from system.web.UI.page but i havent set enny settings regarding sessions?

          1 Reply Last reply
          0
          • S Snowjim

            Hey! I am running Visual Studio 2005 professional. I am now working on a webproject where i need to use sessions I store sessions like this Session.Timeout = 30; Session.Add("profileId", profileId); and im getting the sessions by this code: try { if (Session["profileId"] != null) { mUserId = int.Parse(Session["profileId"].ToString()); postMessage.Controls.Add(LoadControl("~/common/uc/loginBox.ascx")); } } catch (Exception ex) { throw (ex); } The problem is when we reach the if i get a error: 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 \\ section in the application configuration. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: 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 \\ section in the application configuration. Any ide what i need to do? i havent had this problem before? Best Regards Jimmy

            S Offline
            S Offline
            Snowjim
            wrote on last edited by
            #5

            I have notice that its my cs file that is my basePage class that are getting the exception? cant i get the session variable in the my basePage.cs that inherits from web.page? All my webpages(aspx) is inherited from my basePage.cs and that have workt fine, but the sessions dont simes to work in the cs file?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups