Problem solve Get help with specific problems with your technologies, process and projects.

Sharing session data in ASP.NET applications

I have a question about how to shared session data in many ASP.NET applications. I am trying to use ASP.NET State Service for holding shared session data for many .NET Web applications as follows:

Start ASP.NET State Service.
Changed session mode of Web.config file to StateServer
Changed stateConnectionString to Both Web applications are pointing to the localhost state server.
Restart IIS.

Still, it's not working. To check, I set the session in one Web.spplication, and then I tried to access the session variable from another Web application. If not, is there any other way to share session data between different Web applications?
I quit using the built-in session and application state many months ago. In my current applications I create a class containing all of my session state declarations and expose them as properties. When a page loads I create an instance of this session state object and load its contents from an XML file in the file system. Then when the page closes I serialize the values back to XML and write them back to the file system.

This has a number of advantages:

1. Your session state members are strong typed and strong named.
2. All of your session state is in one place and explicitly defined. It is extremely difficult to keep track of session state variables when they are named with literal constants.
3. You can write the session state XML files to a shared system, thus the session state is available not only to multiple applications, but also across multiple servers.

Dig Deeper on Win Development Resources

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.