使用asp.net和状态服务器的两个网站之间的共享会话 [英] Share Session between two web sites using asp.net and state server

查看:114
本文介绍了使用asp.net和状态服务器的两个网站之间的共享会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有IIS 7.5下的两个不同的机器举办了两场完全一样的网站。
ASP.NET状态服务是我的机器上运行,并且在web.config中两个站点有以下code更新:

I have two exactly the same web sites hosted in two different machines under IIS 7.5. ASP.NET state service is running on my machine and the web.config is updated in both sites with the following code:

<sessionState mode="StateServer" stateConnectionString="tcpip=192.168.1.77:42424" cookieless="false" timeout="120"/>

的允许远程连接被设置为1在注册表,以便为第二网站访问状态服务器

The allow remote connection is set to 1 in registry in order for the second web site to access the state server.

这两个网站在同一台机器键:

Both web sites have the same machine key:

<machineKey validationKey="7CB8DF6872FB6B35DECD3A8F55582350FEE1FAB9BE6B930216056C1B5BA69A4C5777B3125A42C4AECB4419D43EC12F168FD1BB887469798093C3CAA2427B2B89" decryptionKey="02FC52E4C71544868EE297826A613C53537DF8FDAF93FA2C64E9A5EF0BA467FB" validation="SHA1" decryption="AES" />

此外这两个网站都在IIS中配置有相同的标识。

Additionally both sites are configured in IIS to have the same Identifier.

我想要做的是,这两个站点共享,例如同一个会话的数据能够做到以下几点:

What I want to do is that both these sites share the same session data for example being able to do the following:

// At web site 1: 
Session["key"] = "value"

// At web site 2:
// Read session value from the other web site
string result = Session["key"]

问题是,我不能设法完成这个测试实在不明白我在做什么错了。

The problem is that I can't manage to accomplish this test and really can't understand what I am doing wrong.

任何想法,可以帮助?

推荐答案

您需要一种方法来说服你的浏览器发送相同的ASP.NET会话cookie不管它访问哪些网站。

You'll need a way to convince your browser to send the same ASP.NET session cookie regardless of which site it visits.

如果该cookie是在提出要求present,那么一个新的会话将获得与该密钥创建的。

If the cookie isn't present on the request, then a new session will get created with that key.

我觉得你可以让浏览器与一些偷偷摸摸的DNS CONFIGS留住关键 - 如果分配的http:// WEBSITE1 .mydomain.com来/ http://website2.domain.com/ 是地址您的网站,然后将ASP.NET会话cookie的域名为domain.com,那么你的浏览器将其发送到两个站点和会话应该共享。

I think you can get the browser to retain the key with some sneaky DNS configs - if you assign http://website1.mydomain.com/ and http://website2.domain.com/ to be the addresses of your sites, then set the domain of the ASP.NET session cookie to "domain.com", then your browser will send it to both sites and the session should be shared.

您还可以用cookie的模式,ASP.NET,并获取会话ID从生成的URL。

You may also be able to use cookieless mode with ASP.NET, and grab the session ID from the generated URLs.

这篇关于使用asp.net和状态服务器的两个网站之间的共享会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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