Powered by Blogger.

Thursday, March 13, 2014

How to optimize session state in asp.net?



In this post we will discuss how to optimize session state in asp.net. As sessions are stored in the sever so it is very much important to optimize session, so that performance will be better.

You can also check out my previous posts on:

- Caching in Asp.Net

- Object Oriented Programming (OOP) concepts in .Net

- Get nth highest lowest salary in SQL Server 2008

- If no session is required for the application then make the session state mode as off in the web.config file like below:

<SessionState Mode="off"/>

When session state mode is off, Session will not be created for the client request. This will improve the performance of the web server.

- Suppose in a page you need only to read session then try to implement page level session like below:

<% @ Page ....... EnableSession="ReadOnly" %>

- In a pag if you do not need session then disable the session like below:

<% @ Page ....... EnableSession="False" %>

- If you need read and write to session then enable the session for the page.

<% @ Page ....... EnableSession="True" %>

This way you can make some optimization of the session.



0 comments

Post a Comment