Error loading object into Session

G

Guest

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("objectname",
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.
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top