<sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" cookieless="false" ></sessionState>
-
打开注册表,运行cmd/regedit,找到节点HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\aspnet_state\Parameters
a.将AllowRemoteConnection值设置为1
b.将Port值设置为a5b8(十六进制),即十进制42424(默认值)
- 分别在网站项目A和网站项目B的Global.asax.cs中加入下面代码
public override void Init()
{
base.Init();
foreach (string moduleName in this.Modules)
{
string appName = "APPNAME";
IHttpModule module = this.Modules[moduleName];
SessionStateModule ssm = module as SessionStateModule;
if (ssm != null)
{
FieldInfo storeInfo = typeof(SessionStateModule).GetField("_store", BindingFlags.Instance | BindingFlags.NonPublic);
SessionStateStoreProviderBase store = (SessionStateStoreProviderBase)storeInfo.GetValue(ssm);
if (store == null)//In IIS7 Integrated mode, module.Init() is called later
{
FieldInfo runtimeInfo = typeof(HttpRuntime).GetField("_theRuntime", BindingFlags.Static | BindingFlags.NonPublic);
HttpRuntime theRuntime = (HttpRuntime)runtimeInfo.GetValue(null);
FieldInfo appNameInfo = typeof(HttpRuntime).GetField("_appDomainAppId", BindingFlags.Instance | BindingFlags.NonPublic);
appNameInfo.SetValue(theRuntime, appName);
}
else
{
Type storeType = store.GetType();
if (storeType.Name.Equals("OutOfProcSessionStateStore"))
{
FieldInfo uribaseInfo = storeType.GetField("s_uribase", BindingFlags.Static | BindingFlags.NonPublic);
uribaseInfo.SetValue(storeType, appName);
}
}
}
}
}ASP.NET_SessionId Cookie的域名要设置相同的域名
相关文章
- 10-14【转】.Net负载均衡使用StateServer进行Session共享
- 10-14关于多台机器之前session共享,sessionState mode="StateServer" 问题的困扰
- 10-14nginx 负载均衡,多站点共享Session
- 10-14多Web服务器之间共享Session的解决方案
- 10-14asp.net基于StateServer的二级域名共享session
- 10-14php实现多域名共享session会话
- 10-14ASP.NET 使用mode=”InProc”方式保存Session老是丢失,无奈改成StateServer 模式。
- 10-14黄聪:WordPress 多站点建站教程(一):怎样开启WordPress多站点功能,实现手机移动端主题开发,与主站用户数据共享
- 10-14asp.net 子应用程序/虚拟目录 session共享
- 10-14ASP.NET中在不同的子域*享Session