Last post Jan 13, 2009 04:46 AM by sandeepreddi
Mar 17, 2008 07:28 PMfirstname.lastname@example.org|LINK
I am trying to come up with a way to let all the web applications under a single website share the same session-scope. My motivation for doing this is due to the way our company's web-based information system has developed over the years - it is basically
an aggregation of several different web-apps which communicate with one another. Currently there are various techniques used to achieve this inter-application state management (ajax calls, url params), however it would be much better if the different apps
could just share the same sessions. Some basic specs for the environment: ASP.NET 2.0, SQLServer state management, all web-apps are under the same website. The basic structure in IIS is as follows:
- webapp one
- webapp two
- webapp three
My first attempt to achieve this was to implement a custom SessionIDManager class, in the hopes that it was the CreateSessionID method of this class that had complete control over the session id. Of course, this was not the case - when I look in the ASPState db, the session ids are postfixed with the web-apps' appid.
Anybody know of a way to achieve this without resorting to implementing a completely custom session state management system?
Thanks for any help!
share session state across multiple web apps
Mar 17, 2008 08:24 PM|nmgomes|LINK
What you really need is to create your own SessionStateStoreProvider. Take a look at
SqlSessionStateStore for inspiration.
Mar 18, 2008 01:30 AM|TonyDong|LINK
Mar 18, 2008 09:04 AMemail@example.com|LINK
Please forgive my ignorance, but where can you specify the application name in the web.config? And, when you say "...and in database" do you mean to manually alter the app name in the ASPState db?
Thanks for your help!
Mar 18, 2008 01:17 PM|TonyDong|LINK
Please see this url for what is application name and where you use it.
Also, you can save session into MS SQL database, so another project can use the session
Look this url for how to share session between class asp and asp.net and also how it save into database
Mar 18, 2008 06:05 PMfirstname.lastname@example.org|LINK
Nice! This looks like just the thing - can't wait to test it out. I'll be sure to mark your response as the answer once I validate.
Mar 18, 2008 06:09 PM|TonyDong|LINK
Mar 19, 2008 02:07 AMemail@example.com|LINK
Tony, could I trouble you for a sample snippet of the sessionState element from a web.config that uses this. Also, am I correct in assuming this technique requires using the aspnetdb database as opposed to the older ASPState?
Mar 19, 2008 01:04 PM|TonyDong|LINK
Not required, the aspnetdb is optional, because you know asp, asp.net 1.1 don't have it .
Mar 19, 2008 06:48 PMfirstname.lastname@example.org|LINK
Hi Again, still fumbling with this...I now see that the ASPState database co-exists with the ASPNETDB database, however I am still at a loss trying to find the specs on the provider element for the built-in SQLSessionStateStore provider. The two links Tony
sent earlier did not really answer the question - the first did explain the provider model, but was pretty specific to membership and roles, and the second discussed implementing a custom session provider. Tony, if I understand you correctly, there is a way
to configure the built-in SQL Session State provider so I will not have to write a custom session store provider. I would be grateful if you could post a snippet of a web.config file that shows how to do this configuration.
Mar 19, 2008 06:54 PMemail@example.com|LINK
Hey Nuno, thanks for your post, somehow I didn't notice it previously! I'm going to have a look at the
SessionStateStoreProvider, hopefully the source for it is available. could then just be a matter of replacing the way it postfixes the session id in the database.
Jon (From Victoria, BC, Canada - North America's West Coast!)
Mar 19, 2008 08:30 PM|TonyDong|LINK
Did you make the demo working on your local machine, I think you need to do so, just ignor the first url, make the share session working and get feeling how it works is most important.
Jan 13, 2009 04:46 AM|sandeepreddi|LINK
You can use session insted of query perameters.
If these two projects are in different virtual directories run as different servers, it's not possible directly share the session in different server process.(assume session attribute is Inproc mode)
To share session in different application, you should use a state server, for example: