Session problem
-
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 -
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 Jimmyby default enablesessionstate is true. Incase it is false,you can enable sessionstate at page level by setting enablesessionstate of page directive to true. Thanks
-
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 JimmyYou 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; }
-
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; }
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?
-
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 JimmyI 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?