By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,627 Members | 2,244 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,627 IT Pros & Developers. It's quick & easy.

Error loading object into Session

P: n/a
We have developed an ASP.NET application that uses a custom component that
we developed.

We are trying to load the custom component into the session state using
"System.Web.HttpContext.Current.Session.Add("objec tname",
customobject)"
and we receive the following error message:
"Session state can only be used when enableSessionState is set
to true, either in a configuration file or in the Page directive."

We have configured session state in both the page and the Web.Config. Is
there an additional step so allow for adding objects to the session? Also, it
is permitted to load objects into the session, correct?

Any assistance would be greatly appreciated.

--
Respectfully,

Andrew Corley
MCSD, MCDBA, Master CIW Designer
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Andrew,

Yes, objects can be loaded into the session state contents, from which you
will need to declare the type when retrieving:

MyType myvar = (MyType) Session["MyStoredType"];

Additionally, check your IIS settings to ensure that the website
configuration is allowing session state. That setting is located in
Properties > Home Directory > Configuration (Applications Settings) > Options

"Enable Session State" should be checked.

I hope this helps!

Thanks,
Ian Suttle
http://www.IanSuttle.com

"Andrew Corley, MCSD, MCDBA" wrote:
We have developed an ASP.NET application that uses a custom component that
we developed.

We are trying to load the custom component into the session state using
"System.Web.HttpContext.Current.Session.Add("objec tname",
customobject)"
and we receive the following error message:
"Session state can only be used when enableSessionState is set
to true, either in a configuration file or in the Page directive."

We have configured session state in both the page and the Web.Config. Is
there an additional step so allow for adding objects to the session? Also, it
is permitted to load objects into the session, correct?

Any assistance would be greatly appreciated.

--
Respectfully,

Andrew Corley
MCSD, MCDBA, Master CIW Designer

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.