asp.net 多站点共享StateServer Session
<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的域名要设置相同的域名
asp.net 多站点共享StateServer Session的更多相关文章
- asp.net 多站点共享FormAuthentication
<authentication mode="Forms"> <forms domain="lizhanglong.com" timeout= ...
- nginx+iis+redis+Task.MainForm构建分布式架构 之 (redis存储分布式共享的session及共享session运作流程)
本次要分享的是利用windows+nginx+iis+redis+Task.MainForm组建分布式架构,上一篇分享文章制作是在windows上使用的nginx,一般正式发布的时候是在linux来配 ...
- .net多站点通过StateServer实现session共享
先在所有要共享站点web.config的<system.web>结点下加 <!--session的mode=StateServer--><sessionState coo ...
- ASP.NET二级域名站点共享Session状态
我的前面一篇文章提到了如何在使用了ASP.NET form authentication的二级站点之间共享登陆状态, http://www.cnblogs.com/jzywh/archive/2007 ...
- 数据库实现多站点共享Session
数据库实现多站点共享Session 多站点共享Session有很多方法,多站点共享Session常见的做法有: 使用.net自动的状态服务(Asp.net State Service); 使用.net ...
- nginx 负载均衡、用数据库存储Session,来实现多站点共享Session[转]
多站点共享Session常见的作法有: 1.使用.net自动的状态服务(Asp.net State Service); 2.使用.net的Session数据库: 3.使用Memcached. 4.使用 ...
- .net学习笔记----二级域名站点共享Session状态
前面一篇文章提到了如何在使用了ASP.NET form authentication的二级站点之间共享登陆状态, http://www.cnblogs.com/jzywh/archive/2007/0 ...
- Nginx + IIS实现负载均衡 Session多站点共享
日子过得太索然无味了,研究了一下,所谓的负载均衡(主要是windows服务器IIS下的).先看看分析图:环境:linux服务器: centos 6.3windows服务器: windows serve ...
- nginx Win下实现简单的负载均衡(2)站点共享Session
快速目录: 一.nginx Win下实现简单的负载均衡(1)nginx搭建部署 二.nginx Win下实现简单的负载均衡(2)站点共享Session 三.nginx Win下实现简单的负载均衡(3) ...
随机推荐
- Instruments性能检测
关于Instruments有网友如是说的:"一句话: 内存开销.运行速度.内存泄露 and so on". 如此简单的回答肯定打发不了咱们各位看官和面试官,当然上述表达和下边的网友 ...
- Openlayers 自定义控件
OpenLayers.Control.YourControl = OpenLayers.Class(OpenLayers.Control, { // may private properties he ...
- RandomAccessFile浅析
RandomAccessFile类中的write方法有以下的注意事项: 首先write方法每次都写入一个字节 api中write方法如下 public void write(int b) throws ...
- erlang学习笔记(2)
函数%###geometry.erl###-module(geometry). 定义-export([area/1, function1/2, function2/0, ...]).area({rec ...
- MCS-51系统中断优先级的软扩展
摘要:鉴于MCS-51系统只提供“二级中断嵌套”,提出扩展51系统中断优先级的纯软件方法.其利用51系统内建的中断允许寄存器IE和中断优先级寄存器IP,通过屏蔽字机制来实现:以C51的形式,给出这种扩 ...
- ldap for ruby
Net::LDAP for Ruby (also called net-ldap) implements client access for the Lightweight Directory Acc ...
- python-模块系列
--> 模块,用一砣代码实现了某个功能的代码集合. 类似于函数式编程和面向过程编程,函数式编程则完成一个功能,其他代码用来调用即可,提供了代码的重用性和代码间的耦合.而对于一个复杂的功能来,可能 ...
- Redis数据结构及相应的命令
Redis可以存储键(key)与5种不同类型值(value)之间的映射,5中不同类型的值分别为字符串(string),列表(list),散列(hash),集合(set)和有序集合(sorted set ...
- Problem 2128 最长子串(kmp+strstr好题经典)
Problem 2128 最长子串 Accept: 134 Submit: 523Time Limit: 3000 mSec Memory Limit : 65536 KB Probl ...
- Android版xx助手之天天酷跑外挂具体分析
Android版xx助手之天天酷跑外挂具体分析 图/文 莫灰灰 背景 近些年来,移动互联网的大肆崛起,潜移默化中影响着人们的生活和工作习惯.当腾讯的微信平台接入手机游戏之后,移动端的游戏也開 ...