.NET Tip of The Day
Learn one new .NET trick every day
Login or Join
.NET Tips & Tricks Community RSS

Those who prefer reading this site through RSS now can also subscribe for updates to .NET Tips & Tricks Community.

Turn off Session State if you're not using it

Since ASP.NET Session State is on by default, you pay the cost in memory even if you don't use it. If you're not using Session State, turn it off and save yourself the overhead. There are serveral ways to do this:

  1. If you're not using Session State at all, turn it off completely via web.config file:

    <system.web>

        <sessionState mode="Off"></sessionState>

        ...


  2. If you're using Session State, but it's required only for a few pages, then first turn it off for all pages:

    <system.web>

        <pages enableSessionState="false">

        ...


    then enable it for a specific page:

    <%@ Page ... EnableSessionState="true" %>

 

P.S. obviously such optimization makes sense only for high-traffic web sites.

5/1/2008
RSS .NET Tip of The Day
Subscribe to receive one tip from the .NET Tips and Tricks Community per day.
Previous Tips of The Day
The best of the .NET Tips & Tricks Community.
.NET Practitioners .NET Tips & Tricks Community
Every .NET practitioner has a trick up in their sleeve. This is the place to share it with other .NET people.
Submit a Tip
Discovered a new trick? Share it with others.
My Tips
Manage tips you authored.