Q

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.

This was first published in October 2004

Dig deeper on Win Development Resources

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close