Session State Management
page 6 of 9
by Joydip Kanjilal
Feedback
Average Rating: 
Views (Total / Last 10 Days): 84951/ 200

Enabling and disabling Session State in ASP.NET

Session State in ASP.NET can be enabled and disabled both at the page and application levels. This section discusses how we can enable and disable Session state at both the page and application levels.

Page Level

We can disable Session State for the pages that do not require access to Session data using the EnableSessionState statement in the Page directive of a page as shown below.

Listing 8

<%@ Page EnableSessionState="False" %>

Session State for a page can also be set to read only for pages that require access to the Session data, but do not modify them.  Refer to the statement below.

Listing 9

<%@ Page EnableSessionState="ReadOnly" %>

Application Level

Session State can also be disabled for all the pages of the application by specifying the same at the application level in the configurations section of the web.config file.

Listing 10

<configuration>
  <system.web>
    <pages enableSessionState="false" />
  </system.web>
</configuration>

It is also possible to set the Session State to read-only for all the pages in the application.

Listing 11

<configuration>
  <system.web>
    <pages enableSessionState="ReadOnly" />
  </system.web>
</configuration>

View Entire Article

User Comments

Title: Really Nice   
Name: PRABHURAJAN_G
Date: 2006-12-22 9:36:38 AM
Comment:
Its really excellent, and i am so cleared with the ideas of session expiration
Title: Firefox and IE process session differently   
Name: Michael
Date: 2006-12-20 11:36:26 AM
Comment:
Hi,

I found firefox keeps same value of "ASP.NET_SessionId" session on every new opened browser window. But IE generated a new "ASP.NET_SessionId". So you could not share sesssion data between new opened browser window in IE.

Michael
Title: Session State questions   
Name: Michael
Date: 2006-12-18 4:28:19 PM
Comment:
Hi Joydip,

I could access to session using both "Response.Redirect(url,false);" and "Response.Redirect(url)". I really could not tell what's the differences between them.

Recently one my cowork set "sessionState mode='StateServer'" instead of "mode='InProc'", because he said the session were lost sometimes. Did you have this kind of problem? If you had it, please tell me how you fixed it.

By the way, if I have big data block, like a big hashtable, Should I save it to session or viewstate? Why?

Thanks.
Michael
Title: Great   
Name: Nadeem Abbasi
Date: 2006-12-08 7:45:55 AM
Comment:
It is very Comprehensive article about Session State Management and also great contribution from Joydip Kanjilal for developers.

--MNA_4U@HOTMAIL.COM
Title: Thanx   
Name: Sudeep
Date: 2006-12-07 3:31:09 AM
Comment:
Very much informative.
Title: state management   
Name: Nitu Singh
Date: 2006-12-06 3:10:28 AM
Comment:
It,s really too good.
Title: Very Nice   
Name: Rajesh
Date: 2006-11-29 8:40:13 PM
Comment:
Very nice article. So many gud points are covered about sessions state storage.

Thanks for the Author.
Title: Abt Session manage ment   
Name: Subhashree
Date: 2006-11-29 5:53:53 AM
Comment:
Excellant Article
Title: I like it too much   
Name: Nguyen Letan
Date: 2006-11-28 9:22:12 PM
Comment:
It's helpful for me. Thanks!
Title: Reema   
Name: Agarwal
Date: 2006-11-26 12:26:24 PM
Comment:
Simply Outstanding
Title: GOOD   
Name: KIRAN
Date: 2006-11-25 5:38:58 AM
Comment:
ITS VERY GOOD
Title: Nice   
Name: Ramana
Date: 2006-11-24 4:37:50 AM
Comment:
Way of explaination is good.
Title: IAtanasov   
Name: Ivan Atanasov
Date: 2006-11-23 9:42:35 AM
Comment:
This is fantastic advice for understand Session State!
Title: Excellant solution to understand session state   
Name: Doss
Date: 2006-11-18 6:03:51 AM
Comment:
It gives easy way to understand session state.Like this i want defn for state mangement .
Title: Session State Management   
Name: A. Ravi Srinivas
Date: 2006-11-18 12:22:56 AM
Comment:
This article seems to be excellent.
I got benefited from Joydip Kanjilal old article on collections as well.
Hope we will get many more from you Joydip Kanjilal
Thanks
Ravi

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2018 ASPAlliance.com  |  Page Processed at 2018-06-24 9:09:49 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search