Click here to Skip to main content
15,891,846 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

As a part of requirement, I need to share single session between 2 different applications (hosted on different machine) withing single domain. (ex: app1.domain.com and app2.domain.com) I am using State Server session management and both the applications are pointing to one same server to store session. In both web applications, machine key is defined same and both web servers pointing to same Server where I am running State Server service for session management. But when I redirect from one application to another application, I am unable to read the session value in second application which is initiated in first application. Need your suggestions. Thanks!

Below changes I am doing on web.config of both the applications:
XML
<sessionState mode="StateServer" stateConnectionString="tcpip=172.24.185.xxx:42424"/>
<machineKey validationKey="77D2713C3E6C46160F278B7F4787A341A8E9010C3C228F8E9522685050F5204ECA0F2BA2169C4F29C1ADD8C3B99E7143A21272A59373BFBEF21C6677D0FF293C" decryptionKey="286F0EA94D5DA2E697C8C148934EF885A6513AD91C044EDFE7DC45027653B830" validation="SHA1" decryption="AES" />


Also in Application_Start() method in Global.asax, I am converting Application domain name to one single name so that session can be shared between 2 apps. (this method is written on both application)

VB
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the application is started
Dim applicationName As String
applicationName = "myApp"

'Change the Application Name in runtime.
Dim runtimeInfo, appNameInfo As FieldInfo
Dim theRuntime As HttpRuntime
runtimeInfo = GetType(HttpRuntime).GetField("_theRuntime", BindingFlags.[Static] Or BindingFlags.NonPublic)
theRuntime = DirectCast(runtimeInfo.GetValue(Nothing), HttpRuntime)
appNameInfo = GetType(HttpRuntime).GetField("_appDomainAppId", BindingFlags.Instance Or BindingFlags.NonPublic)

appNameInfo.SetValue(theRuntime, applicationName)
End Sub
Posted
Updated 23-Jul-14 0:46am
v4

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900