Some facts about Sessions in ASP.NET

The kind of objects that can be stored in a session variable depends on which mode is used:
InProc Mode- objects stored in session state are actually live objects, and so you can store whatever object you have created.
State Server or SQL Server mode, objects in the session state will be serialized and deserialized when a request is processed. So make sure your objects are serializable and their classes must be marked as so. If not, the session state will not be saved successfully.

To enable sessions in the asp.net site you need to
include a pages attribute in web.config:


<pages enablesessionstate="true">



or enable SessionState in the Page directive in your page :

<%@ Page enableSessionState = "true" %>

Also, the System.Web.SessionStateModule should exist in your
httpModules section in the application configuration.

<httpModules>
<add type="System.Web.SessionState.SessionStateModule" name="Session" />
</httpModules>

No comments:

Post a Comment