我的问题与以下问题相反
使用以下命令在 2 个 ASP.NET 应用程序之间共享会话状态SQL服务器
和
如何维护ASP.NET 中的多个 Web 应用程序具有相同的会话 ID。
我们的应用程序使用状态服务器来存储会话信息,并且我们经常希望在同一 Web 服务器上托管同一应用程序的多个版本。
目前,由于 ASP.NET_SessionId
cookie 未存储在任何路径中,因此如果我访问 http://donkey.com/app1
并启动一个新会话,然后,在同一个浏览器会话中,转到 http://donkey.com/app2
,我从 app1 继承会话 ID(以及会话状态)。
有没有办法诱使 ASP.Net 在存储会话 ID cookie 时设置路径,从而打破这种不必要的会话状态共享?
My question is the opposite of the following
Sharing session state between 2 ASP.NET applications using SQL Server
and
How to maintain the same session id across multiple web applications in ASP.NET.
Our application uses state server to store session info and we often want to host several versions of the same application on the same web server.
At the moment, because the ASP.NET_SessionId
cookie is not stored against any path, if I got to http://donkey.com/app1
and start a new session and then, in the same browser session, go to http://donkey.com/app2
, I inherit the session ID (and thus session state) from app1.
Is there a way to cajole ASP.Net to set the path when it stores the session ID cookie and thus break this unwanted sharing of session state?
发布评论
评论(2)
您必须使用不同的
cookieName
对于 web.config 中的每个 Web 应用程序。您也可以通过编程方式进行设置。查看这篇文章。
You'll have to use different
cookieName
for each web application in web.config.You can also programmatically set it. Check this post.
您可以使用子域来实现此目的。例如 http://app1.donkey.com 和 http://app2.donkey.com。默认情况下 - cookie 不跨域共享。
另一种方法是以编程方式设置 cookie 名称,该名称可能基于某些配置值,该配置值确定您正在使用哪个版本。
You can use subdomains to achieve this. like http://app1.donkey.com and http://app2.donkey.com. By default - cookies are not shared across domains.
Another way to do it is set the cookie name programmatically may be based on some config value which determines which version you are using.