EF架构~二级域名*享Session

时间:2021-11-01 08:43:31

回到目录

对于一个有点规模的网站,都会有各个子网站,说是子网站,其实也都是独立的站点,一般通过二次域名来分开,如www.zzl.com,它可以有很多子网站,如image.zzl.com,file.zzl.com,sale.zzl.com,manage.zzl.com,news.zzl.com等等!

而如果希望在各个项目*享你的登陆状态,我们通过的做法是通过cookies实现,但使用cookies就有安全性的问题,因为它的信息保存在客户端,这是重所周知的,而session本身不支持跨域,即使是二级域名,也是不可以的.(cookies可以在各二级域名*享信息),当然,这只是对于inpro的存储方式来说的,如果你是sqlserver或者StateServer的方法,那么,通过一些设置,还是可以实现session的跨域的,下面来说一下实现方式.

一 建立一个httpModule,在页面加载完成后,执行这个方法,将域名的asp.net_sessionId重写

    /// <summary>
/// session共享sessionId
/// </summary>
public class SessionProviderHttpModule : IHttpModule
{
private string m_RootDomain = string.Empty; public void Dispose()
{ } public void Init(HttpApplication context)
{
m_RootDomain = ".mvvm.com"; Type stateServerSessionProvider = typeof(HttpSessionState).Assembly.GetType("System.Web.SessionState.OutOfProcSessionStateStore");
FieldInfo uriField = stateServerSessionProvider.GetField("s_uribase", BindingFlags.Static | BindingFlags.NonPublic); if (uriField == null)
throw new ArgumentException("UriField was not found"); uriField.SetValue(null, m_RootDomain); context.EndRequest += new System.EventHandler(context_EndRequest);
} void context_EndRequest(object sender, System.EventArgs e)
{ HttpApplication app = sender as HttpApplication;
for (int i = ; i < app.Context.Response.Cookies.Count; i++)
{
if (app.Context.Response.Cookies[i].Name == "ASP.NET_SessionId")
{
app.Context.Response.Cookies[i].Domain = m_RootDomain;
}
}
}
}

二 将这个httpModule注入到项目中

web.config方法

 <sessionState cookieless="false"
timeout=""
mode="StateServer"
stateConnectionString="tcpip=localhost:42424"/>
<httpModules>
<add name="CrossDomainCookieModule"
type="EntityFrameworks.Application.Core.HttpModule.SessionProviderHttpModule,EntityFrameworks.Application.Core"/>
</httpModules>

预处理程序方法

    /// <summary>
/// 预处理代码
/// </summary>
public class PreApplicationStartCode
{
public static void Start()
{
// Register our module
Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility.RegisterModule(typeof(EntityFrameworks.Application.Core.HttpModule.SessionProviderHttpModule));
}
}

三 设置注册表相关项,启动asp.net的session服务,如图

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\aspnet_state\Parameters

AllowRemoteConnection值为1,Port值可以任意设置,默认为42424

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZoAAAGtCAIAAACgGyUhAAAgAElEQVR4nO2dd/gtRXnHz99GjS2xxRgTBERABAEBwZ+AVBUQEUREqki5dC4dDlx6771fehWQKr1jiairEEVUFKXHCElAzLP5Y2CZO2+Zd8vZMuc7z+e5z545s7Mz7+x8frN7ztk7yh55CAAAhs7MzMwoe+ShHAkJCWnIaTwev6mzzs0KAACVCXX2lvm2cfzdR7f9u49u+9b5t33r/Nu9dYHt3rbAdm9bYNbbF5z19gVnvf1j2//9x7b/+4W2f8dCO7xjoR3e8fEd3vnxHd+58I7vWnjHdy2y07sW2endi+z87kV3fs+iO7/nE7u85xO7/MNiu/zDYrv+42K7/uMnd33vJ3d77+K7vXfx3d63xOz3LTH7/UvMfv+ndn//p3b/wJK7f2DJPT641B4fXGrPDy695z8tvec/Lb3Xhz6914c+vdeHltn7n5fZ+5+X3fvDy+7z4WX3+fBy+/zLcvv+y2f2/chn9v3I8vt9ZPn9/nX5/f51hf3/bYX9/+2z+8/32fF8M+P5Zg746MwBH/3cAfN/7sD5Vzxw/hUPXGClOQusNGfBleYsuPJBC6580Mc+f9DHPn/wQqscvNAqBy+06iEfX/WQj696yMKrHbrwaocuvPphi6x+2CJrHLboGocvusbhi655+CfWPOITXzhisS8csdgXj/yk40tHLf6loxZf66gl1jp6ibWPXmLtoz+19jGfWueYJdc5ZskvH7vkl49dat3jllr3uKXXPW7prxy/9FeO//R6x396vROW+eoJy3z1hGXWP3HZ9U9cdv0Tl9vgpOU2OGm5r530ma+d/JkNT15+w5OX3/CU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K+2VSkqr1C0g106oa73IGnU0h0FlKNKizoQCdgTdxOlMuK4aboLNp7nIGnU0ho9FoJt0k6axj0U4yzQg667pdE0xslzPobAph78enlGiXu/RrKwlddkBnAIBEgM4AAIkAnQEAEgE6AwAkAnQGAEgE6AwAkAjQGQAgEd7UWWdfiUNCQkJqKM3MzIxa/gocEhIS0oTS/wMFjiyGBydIBQAAAABJRU5ErkJggg==" alt="" />

四 当我们设置好上面内容后,我们的session共享就完成了,测试后的结果,如图

EF架构~二级域名*享Session

EF架构~二级域名*享Session

通过图上我们可以看到,它们的ASP.NET_SessionId是相同的,我们知道,浏览器在没有进行用户session写入时,每次刷新,这个值都会变,但当用户使用session序列化后,这个值就固定了,当你把浏览器关闭后,这个值也同时消失,可以说,它是服务器端session的唯一标示,这个值如果相同,服务器就会认为,你的网站是在同一个域下的,它们的信息是共享的,反之,它们就是自立独立的,就像两个应用程序域一样,它们之间是不能相互通讯的.

回到目录

EF架构~二级域名*享Session的更多相关文章

  1. &period;net学习笔记----二级域名站点共享Session状态

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

  2. ASP&period;NET二级域名站点共享Session状态

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

  3. asp&period;net 配置二级域名的共享session,并实现sso单点登录

    公司最近做了一个新网站.原先网站的网址是www.xxxx.com.新做的网站要部署到info.xxxx.com.这两个网站要实现单点登录.而新老网站本身机构的原因,对于登录状态的判断,说白了就是对于s ...

  4. SpringCloud微服务架构分布式组件如何共享session对象

    一.简单做一个背景说明1.为说明问题,本文简单微服务架构示例如下 2.组件说明分布式架构,每个组件都是集群或者主备.具体说明如下:zuul service:网关,API调用都走zuul service ...

  5. &period;net主站和二级域名下实现session共享

    public class CrossDomainCookie : IHttpModule { private string m_RootDomain = string.Empty; #region I ...

  6. ASP&period;NET中在不同的子域*享Session

    天遇到了这个问题,于是研究了一下.要解决这个问题,首先就要明白一些Session的机理.Session在服务器是以散列表形式存在的,我们都知道Session是会话级的,每个用户访问都会生成一个Sess ...

  7. *域名和二级域名cookie共享删除和修改

    原文地址: https://segmentfault.com/a/1190000006932934

  8. &period;NET二级域名共享Session

    ASP.NET二级域名站点共享Session状态 今天, 我要写的是如何在二级域名站点之间,主站点和二级域名站点之间共享Session. 首先, Session要共享,站点之间SessionID必须要 ...

  9. *域名和二级域名共享cookie及相互删除cookie

    在CSDN看到一个cookie设置domain时,如何删除的问题, 自己也只知道domain设置为*域名时可以被其他二级域名共享,但是如何删除还是有一点搞不清楚,所以特意测试了下cookie和dom ...

随机推荐

  1. 虚拟机配置光盘为yum源

    很多时候, 我们装系统用的光盘就足够充当我们的软件源了. 但是, 怎么才能配置好让光盘成为yum的软件源, 让yum命令找到这个地方, 从而进行软件的安装. 1. 在虚拟机中把光盘挂载上 挂载上之后, ...

  2. C&plus;&plus;混合编程之idlcpp教程&lpar;一&rpar;

    我是C++语言的忠实拥趸,由于在上学时经历了资源匮乏的DOS时代,对C/C++这种更加接近硬件的语言由衷的喜爱.一直以来也是已C++作为工作的语言,对别的语言那是不屑一顾.在java火爆流行的时候,没 ...

  3. 关于BIOS的一点东西

    关于BIOS的一点东西 编辑删除转载2016-05-20 00:36:36 去把BIOS的每个单词意思都有道一遍就都明白了,BOOT是更改 启动顺序的(台式机一直按del键就会进入BIOS界面,用上下 ...

  4. *上—数据仓库、数据挖掘、OLAP三者之间的区别

    数据仓库可以作为数据挖掘和OLAP等分析工具的资料来源,由于存放于数据仓库中的资料,必需经过筛选与转换,因此可以避免分析工具使用错误的资料,而得到不正确的分析结果. 数据挖掘和OLAP同为分析工具,其 ...

  5. 微信jsapi支付的坑

    1.显示 redirect_uri 参数错误  因为手机支付是需要微信授权的,所以检查配置授权域名地址是否正确填写(登陆微信公众平台,地址:https://mp.weixin.qq.com/cgi-b ...

  6. JDBC连接数据库和释放连接

    用久了hibernate现在对于JDBC是怎么实现数据库的连接和释放,所以特地总结下关于JDBC的知识,目的是用于提醒自己很多Java的基础知识需要健全. package com.ssh.action ...

  7. JAXB2序列化XML

    Jaxb2 实现JavaBean与xml互转 http://zhuchengzzcc.iteye.com/blog/1838702 JAXBContext类,是应用的入口,用于管理XML/Java绑定 ...

  8. JavaWeb之原生数据库连接

    我们在开发JavaWeb项目时,常会需要连接数据库.我们以MySQL数据库为例,IDE工具为eclipse,讲述数据库连接与基本操作. 第一步,我们在Web项目的WebContent中建一个简单的前端 ...

  9. &lbrack;openwrt&rsqb; uci 的shell和lua接口

    uci是openwrt上配置操作的接口,不管是自动化的shell脚本,还是使用luci来二次开发配置界面,都会用到这部分知识. uci提供了lua, shell, c接口,这里主要用到了前两种 she ...

  10. ImageMagick

    http://blog.csdn.net/lan861698789/article/details/7738383 1.官网 http://www.imagemagick.org/script/ind ...