Click here to Skip to main content
12,953,263 members (84,719 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked
Posted 11 Oct 2013

ASP.NET Session States in SQLServer for multiuser and loadbalancing solution

, 11 Oct 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
This topic is for those who want to manage multi server websites and load balancing.Prerequisites:IIS 6.0 or higher.NET Framework 2.0,

Editorial Note

This articles was originally at but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.

This topic is for those who want to manage multi server websites and load balancing.


  • IIS 6.0 or higher
  • .NET Framework 2.0, 3.5
  • VS 2008, 2005
  • ASP.NET 2.0 or higher

How To in WinXP Professional?

  1. In SQL Server management consol
  2. Open file from path "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallPersistSqlState.sql"
  3. Execute this script file on master database
  4. Go to command prompt of windows (Start->Run->cmd)
  5. Type net stop w3svc
  6. press Enter key
  7. Type net start w3svc
  8. press Enter key
  9. type iisreset
  10. press Enter key
  11. type net start aspstate
  12. press Enter key
  13. type aspnet_regsql
  14. press Enter key
  15. follow the instruction (by default next, next) (specify database aspstate)
  16. Type net stop w3svc
  17. press Enter key
  18. Type net start w3svc
  19. press Enter key
  20. type iisreset
  21. press Enter key
  22. type net start aspstate
  23. press Enter key


  • modify your web.config with following
 <sessionState mode="SQLServer" sqlConnectionString="data source=; user id=<username>;password=<password>; "


timeout="20" />

  • (optional) modify your machine.config for all web servers with follwoing (dont user following, generate your new machine key)

<machineKey validationKey='A130E240DF1C49E2764EF8A86CEDCBB11274E5298A130CA08B90EED016C0


decryptionKey='2CC37FFA8D14925B9CBCC0E3B1506F35066FEF33FEB4ADC8' validation='SHA1'/>





This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

ASP.NET Community
United States United States
The ASP.NET Wiki was started by Scott Hanselman in February of 2008. The idea is that folks spend a lot of time trolling the blogs, googlinglive-searching for answers to common "How To" questions. There's piles of fantastic community-created and MSFT-created content out there, but if it's not found by a search engine and the right combination of keywords, it's often lost.

The ASP.NET Wiki articles moved to CodeProject in October 2013 and will live on, loved, protected and updated by the community.
Group type: Collaborative Group

765 members

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170525.1 | Last Updated 11 Oct 2013
Article Copyright 2013 by ASP.NET Community
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid