1. <sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" cookieless="false" ></sessionState>

  2. 打开注册表,运行cmd/regedit,找到节点HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\aspnet_state\Parameters

      a.将AllowRemoteConnection值设置为1

      b.将Port值设置为a5b8(十六进制),即十进制42424(默认值)

  3. 分别在网站项目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的更多相关文章

  1. asp.net 多站点共享FormAuthentication

    <authentication mode="Forms"> <forms  domain="lizhanglong.com" timeout= ...

  2. nginx+iis+redis+Task.MainForm构建分布式架构 之 (redis存储分布式共享的session及共享session运作流程)

    本次要分享的是利用windows+nginx+iis+redis+Task.MainForm组建分布式架构,上一篇分享文章制作是在windows上使用的nginx,一般正式发布的时候是在linux来配 ...

  3. .net多站点通过StateServer实现session共享

    先在所有要共享站点web.config的<system.web>结点下加 <!--session的mode=StateServer--><sessionState coo ...

  4. ASP.NET二级域名站点共享Session状态

    我的前面一篇文章提到了如何在使用了ASP.NET form authentication的二级站点之间共享登陆状态, http://www.cnblogs.com/jzywh/archive/2007 ...

  5. 数据库实现多站点共享Session

    数据库实现多站点共享Session 多站点共享Session有很多方法,多站点共享Session常见的做法有: 使用.net自动的状态服务(Asp.net State Service); 使用.net ...

  6. nginx 负载均衡、用数据库存储Session,来实现多站点共享Session[转]

    多站点共享Session常见的作法有: 1.使用.net自动的状态服务(Asp.net State Service); 2.使用.net的Session数据库: 3.使用Memcached. 4.使用 ...

  7. .net学习笔记----二级域名站点共享Session状态

    前面一篇文章提到了如何在使用了ASP.NET form authentication的二级站点之间共享登陆状态, http://www.cnblogs.com/jzywh/archive/2007/0 ...

  8. Nginx + IIS实现负载均衡 Session多站点共享

    日子过得太索然无味了,研究了一下,所谓的负载均衡(主要是windows服务器IIS下的).先看看分析图:环境:linux服务器: centos 6.3windows服务器: windows serve ...

  9. nginx Win下实现简单的负载均衡(2)站点共享Session

    快速目录: 一.nginx Win下实现简单的负载均衡(1)nginx搭建部署 二.nginx Win下实现简单的负载均衡(2)站点共享Session 三.nginx Win下实现简单的负载均衡(3) ...

随机推荐

  1. 如何启用Oracle EBS Form监控【Z】

    前言: 有时候,因某些需要,必须知道Oracle的Form被使用的情况,以方面我们做出决策: 例如,如果某个Form被使用的次数非常多,那么,这个Form的相关SQL代码就应该优先处理,以减少服务器负 ...

  2. Java web 基础

  3. Properties文件的XML格式(转)

    想必大家都用过*.properties文件,作为配置文件.但是,如果该文件写入了中文,待编译后内容就会成为乱码,使用native命令也好.使用ant执行编码转换也好,多少有点麻烦,与其如此,我们不如直 ...

  4. 关于JPA多数据源的部署persistence.xml文件配置以及对应实现类注入

      <?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http: ...

  5. Spring-----Spring整合Struts2实例

    转载自:http://blog.csdn.net/hekewangzi/article/details/51713058

  6. dedecms一些技巧

    有时我们很多栏目公用一个模版,但栏目展示的图片又不同,并且要考虑到多级栏目下的 {dede:field.typeid function="GetTopid(@me)"/} 这个能获 ...

  7. Java提高学习之Object(2)

    Equality 问:euqals()函数是用来做什么的? 答:equals()函数可以用来检查一个对象与调用这个equals()的这个对象是否相等. 问:为什么不用“==”运算符来判断两个对象是否相 ...

  8. Cookies与保持登录(新浪微博的简单模拟登录)

    Cookies与保持登录(新浪微博的简单登录) .note-content {font-family: "Helvetica Neue",Arial,"Hiragino ...

  9. Javascript的数组操作[转]

    1.shift:删除原数组第一项,并返回删除元素的值:如果数组为空则返回undefined var a = [1,2,3,4,5]; var b = a.shift(); // 结果 a:[2,3,4 ...

  10. mysql登录错误或者密码错误

    一.mysql登录错误 mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root ...