如何在单个域下的不同网站之间共享会话。 [英] How to share session between different web sites under single domain.

查看:71
本文介绍了如何在单个域下的不同网站之间共享会话。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





作为要求的一部分,我需要在单个域之间共享2个不同应用程序(托管在不同机器上)之间的单个会话。 (例如:app1.domain.com和app2.domain.com)我正在使用State Server会话管理,两个应用程序都指向同一个服务器来存储会话。在两个Web应用程序中,机器密钥定义相同,两个Web服务器都指向同一个服务器,我正在运行状态服务器服务以进行会话管理。但是当我从一个应用程序重定向到另一个应用程序时,我无法读取在第一个应用程序中启动的第二个应用程序中的会话值。需要你的建议。谢谢!



我正在对两个应用程序的web.config进行以下更改:

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:

<sessionState mode="StateServer" stateConnectionString="tcpip=172.24.185.xxx:42424"/>
<machineKey validationKey="77D2713C3E6C46160F278B7F4787A341A8E9010C3C228F8E9522685050F5204ECA0F2BA2169C4F29C1ADD8C3B99E7143A21272A59373BFBEF21C6677D0FF293C" decryptionKey="286F0EA94D5DA2E697C8C148934EF885A6513AD91C044EDFE7DC45027653B830" validation="SHA1" decryption="AES" />





同样在Global.asax的Application_Start()方法中,我将应用程序域名转换为单个名称,以便可以在2个应用程序之间共享会话。 (这个方法都写在两个应用程序上)





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)

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

推荐答案

这篇关于如何在单个域下的不同网站之间共享会话。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆