简体   繁体   English

在两个ASP.NET应用程序之间共享会话,其中一个嵌套在另一个ASP.NET应用程序中

[英]Sharing session between two ASP.NET applications, where one is nested within the other

So, before you ask "what the heck do you mean, one is nested within the other?" 那么,在你问“你的意思是什么之后,一个嵌套在另一个之内?” I'll explain it as simply as I can. 我会尽可能简单地解释一下。

A .NET web application (A) existed. 存在.NET Web应用程序(A)。 A supplementary application (B) was built that works off several of the same core assemblies. 构建了一个补充应用程序(B),它可以处理几个相同的核心组件。 A previous consulting company had somehow "installed" application B within application A so that B could piggyback off of A's session. 之前的一家咨询公司以某种方式应用程序A中“安装”了应用程序B 以便B可以背负A的会话。 So, something like this: 所以,像这样:

- Application A (C:\Inetpub\wwwroot\ApplicationA)
    + Application B (C:\Inetpub\wwwroot\ApplicationA\sup\ApplicationB

The previous company left zero documentation on how or why they did this, but it worked for them. 之前的公司没有留下关于他们如何或为什么这样做的文档,但它对他们有用。 My dilemma is now this: Application A was upgraded, rendering B useless. 我现在面临的困境是:应用程序A升级,使B无用。 I updated B to run off the new core provided by A, but by the time I was finished, another team had decimated the previous production and test servers and I can't get a backup to see how it was configured. 我更新了B来运行A提供的新核心,但是当我完成时,另一个团队已经摧毁了之前的生产和测试服务器,我无法获得备份以查看它是如何配置的。

After a bunch of futsing around, I was able to replicate the hierarchy above within a single IIS application and pool by chopping apart the web.config file for B and removing the duplicate sections -- the ones that already existed in A's web.config. 经过一系列的改进后,我能够通过切断B的web.config文件并删除重复的部分 - 在A的web.config中已存在的部分,在单个IIS应用程序和池中复制上面的层次结构。 I also dumped all of the files from B's bin folder into A's bin folder. 我还将B的bin文件夹中的所有文件转储到A的bin文件夹中。

Both sites compile and are served by IIS, but I cannot read anything out of A's session using this structure. 两个站点都编译并由IIS提供服务,但我无法使用此结构从A的会话中读取任何内容。 I'm not surprised by that result, but I need to find a workaround. 我对这个结果并不感到惊讶,但我需要找到一个解决方法。 In short, A has a sessionID stored in its session that I need to use to obtain a datasource in B, due to some crazy licensing rules imposed by the creators of A (that sessionID needs to be passed to each function in their core API for user authorization). 简而言之,A有一个存储在其会话中的sessionID,我需要用它来获取B中的数据源,因为A的创建者施加了一些疯狂的许可规则(sessionID需要传递给其核心API中的每个函数)用户授权)。

Any ideas on why the functionality no longer works (assuming I've replicated the old environment correctly), or how I could work around it? 关于为什么功能不再有效的任何想法(假设我已经正确地复制了旧环境),或者我如何解决它? Moving to a SQL server for session state is not an option -- I cannot change anything about application A. 移动到SQL服务器以获取会话状态不是一个选项 - 我无法更改有关应用程序A的任何内容。

I've looked a little bit at A's code (as much as I dare with Reflector), and the variable that I'm trying to retrieve from the session is still there and being used. 我看了一下A的代码(就像我敢用Reflector一样),我试图从会话中检索的变量仍在那里并被使用。

Any thoughts would be great! 任何想法都会很棒!

Since they are two separate applications, they (obviously) have two different session scopes. 由于它们是两个独立的应用程序,因此它们(显然)具有两个不同的会话范围。 You could have a session in one but not the other, and the session in A could expire before the session in B, forcing A to create a new session while B is still using the old one. 您可以在一个会话而不是另一个会话中,A中的会话可以在B中的会话之前到期,强制A在B仍在使用旧会话时创建会话。 There's nothing linking A to B or vice-versa, so logically there's no straighforward way they even could share objects, as there's no meaningful correlation between them. 没有任何东西将A链接到B,反之亦然,所以逻辑上没有直接的方式它们甚至可以共享对象,因为它们之间没有任何有意义的相关性。

The short of it is - you can't (easily) directly share session to session data between two different applications. 缺点是 - 您不能(轻松)直接在两个不同的应用程序之间共享会话数据。 A frequent solution for this problem is to pass a common ID between the two applications via querystring or cookie (if they are on the same domain), and both use that ID to refer back to a common record in a database they can both access. 此问题的常见解决方案是通过查询字符串或cookie(如果它们位于同一域中)在两个应用程序之间传递公共ID,并且都使用该ID引用它们都可以访问的数据库中的公共记录。 From that point information can be shared via the database. 从那时起,可以通过数据库共享信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 跨应用程序的ASP.NET MemoryCache共享 - ASP.NET MemoryCache Sharing Across Applications 在Asp.Net Core中注入一个带参数的服务,其中一个参数是嵌套服务,其他参数是常用变量 - Inject a service with parameters in Asp.Net Core, where one parameter is a nested service and the other parameters are usual variables 通过.NET客户为例共享ASP.NET应用程序和WCF web服务之间的会话数据 - Sharing session data between ASP.NET app and WCF Webservice through .NET clinet 在ASP.NET和Silverlight之间共享程序集 - Sharing an assembly between ASP.NET and Silverlight 在单个解决方案中,我在DNX / ASP.NET 5项目(project.json / xproj)和其他C#项目(csproj)之间共享代码有哪些选择? - What are my options for sharing code between DNX / ASP.NET 5 projects (project.json / xproj) and other C# projects (csproj) within a single solution? 使用Java applet共享ASP.NET会话cookie - Sharing ASP.NET session cookies with a Java applet 在同一解决方案中的两个Asp.Net Web应用程序之间共享文件夹 - Share a folder between two Asp.Net web applications in the same solution 在两个asp.net MVC Web应用程序之间传递非ASCII字符将无法识别 - Passing non-ASCII characters between two asp.net MVC web applications will not be recognized 验证我在经典ASP和.NET Web服务之间共享“会话”的方法 - Validate my approach for sharing “session” between Classic ASP and .NET webservices 嵌套的ASP.NET页无法访问彼此的Session变量 - Nested ASP.NET pages can't access each other's Session variables
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM