Last post Jun 17, 2011 08:19 AM by email@example.com
Jun 16, 2011 06:32 AM|HenkAJ|LINK
I have tried to share session data between two web applciations.
I did the following:
• Web1 – Save a string value to the session this.Session[“DATA”] = “Test this”;
• Web1 Navigates to Web 2
• Web2 – Read the session value null!= this.Session[“DATA”]? (string)this.Session[“DATA”]:”No Session data”
I have configured the sessionstate element in both web config’s with the following:
<sessionState mode="StateServer" cookieless="UseCookies" stateConnectionString="tcpip=WIN-2CNGJ18APIG:42424" timeout="50" stateNetworkTimeout="10"/>
Having it configured to “StateServer” does not work.
When I change it to be SQL (“SQLServer” and having installed and setup everything using aspnet_regsql.exe), the state works as expected.
I can set the session in web1 and read it in web2.
I don’t want to use SQL server, because of the nature of the projects I need this for and using aspnet_state.exe is part of the framework already, so obviously I want to use this instead.
I have also implemented code I found online by Peter Femiani (a workaround) to set the application id’s of the two web apps to be the same. This approach works for the SQL configuration and I thought, will also work for Stateserver configuration.
I have tried to run the aspnet_state.exe service on 3 different machine configurations
• Windows 7 – 64 and 32 bit
• Windows 2k8R2 – 64 bit
The service is running and I can see the memory increase every time I read/write from/to the session. (on all 3 machines)
I have traced the traffic and used processmonitor and both confirm that I am connecting to aspnet_state.exe, but for some reason
WEB2, have no session information (it is null).
I am at my end of things to try and was hoping more experienced folks might be able to help me.
Jun 16, 2011 08:06 AMfirstname.lastname@example.org|LINK
this is interesting question. yes its possible to share the seeion between 2 web applications.
chage your config entry like below
<sessionState mode="SQLServer" sqlConnectionString="Data Source=.\SQLEXPRESS;User
Id=test;Password=test;Application Name=AppName" />
<machineKey validationKey="SOMEKEY" validation="SHA1"
Jun 16, 2011 08:09 AM|Huske|LINK
The problem is that you have to different applications. If there was one application in a web farm then this would have worked. But sharing sessions among appilcations is, as far as I know, not possible with the out of the box solution. However, there is
an article on CodeProject that shows how to do it. Have a look here
But this solution is for SQL Server as a state management which you said is not good enough for you.
Jun 16, 2011 08:11 AM|GPankaj|LINK
Is your Web.Config same for both the site and also verify the machine key.
Jun 16, 2011 07:20 PM|HenkAJ|LINK
Yes, my web.config are the same and same machine key as well.
As indicated, I get it to work for SQL, but that is not what I am looking to do.
The next question might be.
How does Aspnet_state key lookup work compared to SQL. SQL uses the SessionID+AppID, but what is used when using aspnet_state.exe?
Does anyone know?
Jun 16, 2011 07:21 PM|HenkAJ|LINK
Thank you for your reply, but I already got it working for SQL and is looking to use ASPNET_STATE.exe instead. Do you have any ideas?
Jun 17, 2011 08:16 AM|sandy060583|LINK
ASPNET_STATE service is started on all machine where you deployed your website? plz check that also.
Jun 17, 2011 08:19 AMemail@example.com|LINK
i dont think out process session state will share the session.