简体   繁体   English

.Net应用程序变量跨应用程序渗漏

[英].Net Application Variables bleeding across applications

I have a couple of websites that have a shared code base as they are essentially the same website, except one is for the UK market and the other is for the US market. 我有两个共享代码库的网站,因为它们本质上是同一网站,除了一个网站用于英国市场,另一个网站用于美国市场。 As well as sharing a code base, they also share a database with a very basic CMS so that each website can have some different content. 他们不仅共享代码库,而且还使用基本的CMS共享数据库,以便每个网站可以具有一些不同的内容。

On the sites we have an admin page which can be used to set some HttpContext.Current.Application variables for each website, things that don't change all that often, but that we may want to change at a moments notice without having to update config files etc. 在这些站点上,我们有一个管理页面,该页面可用于为每个网站设置一些HttpContext.Current.Application变量,这些事情不会经常更改,但是我们可能希望立即更改而无需更新配置文件等

Now this has been working fine for a number of years now on a server 2003 box with IIS 6. Just yesterday we upgraded to a shiny new Server 2012 box with IIS 8 and we are now having issues with the Application objects. 现在,在带有IIS 6的Server 2003机器上,这种方法已经运行了好多年。就在昨天,我们升级到了带有IIS 8的崭新的Server 2012机器,现在应用程序对象出现了问题。

To cut a long story short, now when an application variable is set on one website, it is being set across both sites, so the UK market sees the US application objects and vice versa, depending on which one was set last. 简而言之,现在在一个网站上设置了应用程序变量后,便同时在两个站点上都进行了设置,因此英国市场会看到美国的应用程序对象,反之亦然,这取决于最后设置的对象。

The application objects are pulled from a database based on a market code, and that is all working fine (the code hasn't changed in at least a couple of years now), and I have written some logging to confirm that the correct objects are being loaded for each website. 应用程序对象是根据市场代码从数据库中提取的,并且一切正常(至少在几年内代码没有更改),并且我编写了一些日志记录以确认正确的对象是为每个网站加载。

Each website has its own application pool, so I really can't see how this is happening. 每个网站都有自己的应用程序池,所以我真的看不到这是怎么回事。 I have tested the sites on Server 2008 with IIS 7.5 and they behave fine there, similarly, I run a Windows 8 dev machine with IIS 8 with what I think is an identical setup to the new live servers (the app pools are configured the same and everything) and both sites do the correct thing there. 我已经在带有IIS 7.5的Server 2008上测试了站点,并且在那里表现良好,类似地,我运行带有IIS 8的Windows 8开发人员计算机,我认为与新的活动服务器的设置相同(应用程序池配置相同)以及所有内容),并且两个站点都在那里做正确的事情。

Has anyone ever heard of this sort of issue before, and does anyone have any suggestions for things I can look into to fix this? 有人听说过这种问题吗?有人对我可以解决的问题有任何建议吗? I thought it wasn't even possible to share Application objects across separate applications, are my assumptions wrong there? 我认为甚至不可能在单独的应用程序之间共享应用程序对象,我的假设在那里吗?

Many thanks! 非常感谢!

Mark 标记

This sounds like a configuration problem, are you sure those site have different market codes? 这听起来像是配置问题,您确定这些站点具有不同的市场代码吗? Looks like the queries returns wrong values for the application objects. 看起来查询为应用程序对象返回了wrong值。

Ok, so it turns out, it was a configuration issue, not with the websites or even IIS. 好的,事实证明,这是一个配置问题,而不是网站甚至IIS。 It in fact turned out that our sysadmin, when changing the DNS for the websites, accidentally changed the US website to the UK IP address, so both sites were the same application after all. 实际上,事实证明,我们的系统管理员在更改网站的DNS时不小心将美国网站更改为英国IP地址,因此,两个网站毕竟是同一应用程序。 I'm afraid it never even occurred to me to ping the sites to check the IP addresses, and we all now feel suitably silly for not spotting it sooner. 恐怕我什至从未对站点进行ping检查IP地址,我们现在都觉得很傻,因为没有更早发现它。 I can only put it down to a ridiculously early start in the morning to do the change over, resulting in a bunch of over tired developers on a wild goose chase. 我只能把它放到一个可笑的清晨开始,以进行更改,从而导致一堆疲惫的开发人员忙得不可开交。

Still, if anyone else has a similar issue, perhaps this will help them. 不过,如果其他任何人都有类似的问题,也许这会对他们有所帮助。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM