ASP.NET 和应用程序隔离
使用 IIS 6,应用程序隔离是基于应用程序池进行的吗?如果是这样,当一个应用程序池中有多个虚拟目录时会发生什么情况?它们是否都共享相同的内存?如果一个虚拟目录崩溃,所有其他应用程序也会崩溃吗?
Using IIS 6, is Application Isolation happen based on the Application Pool? If so, what happens when there is more than one Virtual Directory in one Application Pool? Do they all share the same memory and if one Virtual Directory crashes, all the other apps crash as well?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果一个虚拟目录中的功能崩溃,是的,它可能会崩溃或损害同一应用程序池中的其他应用程序,包括其他虚拟目录中的应用程序。通过将应用程序放入单独的应用程序池来保护它们。
虚拟目录本身并不隔离内存或资源。这还有其他含义。例如,一个应用程序中的静态变量可能会受到同一应用程序池中另一应用程序中的静态变量设置的影响。
在 IIS 6 中,应用程序池的目的非常简单:隔离应用程序,这样一个应用程序崩溃就不会导致其他应用程序崩溃。在 IIS 7 中,这仍然是主要目的,但是有更多内容。
编辑:澄清一下:每个应用程序池都是它自己的“工作进程”,一个崩溃不会伤害其他应用程序池。每个虚拟目录很简单:一种使 IIS 表现得好像该位置有一个目录的方法。当您创建与其指向的文件夹具有相同名称和位置的虚拟目录时,默认情况下实际上不会执行任何操作。您可以出于多种原因使用虚拟目录,除了使 URL 符合您的意愿之外:您可以使用它们来确保安全。正如我们一直在讨论的,您可以使用它们将调用放入特定的应用程序池中。
人们经常将虚拟目录与 Web 应用程序等同起来,因为您通常希望通过 Web 应用程序来使用虚拟目录的配置功能。
会话状态仅在 Web 应用程序内维护,而不是在应用程序池中的所有 Web 应用程序之间维护。要存储不同 Web 应用程序之间共享的值,您必须执行其他操作。 ASP.NET 缓存、cookie、数据库等。将应用程序中的不同文件夹作为不同的虚拟目录和单独的应用程序池会将它们放入不同的进程中并破坏它们的共享会话状态。
If functionality in one Virtual Directory crashes, yes, it may crash or harm other applications in the same Application Pool, including those in other Virtual Directories. Protect your applications by putting them into separate Application Pools.
Virtual directories do not themselves segregate memory or resources. This has other implications as well. For example, your static variables in one application can be affected by setting static variables in another application in the same application pool.
In IIS 6, the point of an application pool is quite simple: to segregate applications so that one crashing does not bring down the rest. In IIS 7, that is still the main purpose, but there is a little more to it.
Edit: To clarify: Each Application Pool is it's own "worker process", and one crashing won't hurt other Application Pools. Each Virtual Directory is simply that: a way to make IIS act as if there was a directory at that place. When you create a Virtual Directory with the same name and location as the folder it points to, by default that doesn't really do anything. You can use virtual directories for a variety of reasons, in addition to making URL's be as you wish: You can use them for security. And you can use them to put calls into particular application pools, as we've been discussing.
People often equate Virtual Directories with Web Applications because that is usually where you want to use the configuring power of virtual directories--by web app.
Session State is only maintained within the Web Application, not amongst all the Web Applications in an Application Pool. To store values shared between different Web Applications, you'd have to do something else. The ASP.NET cache, cookies, db, etc. Putting different folders in your application as different Virtual Directories and Separate Application pools would put them in different processes and destroy their shared session state.
不同的虚拟目录可以有不同的应用程序池。如果他们共享同一个应用程序池并崩溃,那么整个应用程序就会崩溃。如果您为虚拟目录配置了不同的应用程序池,那么它们是隔离的。
请记住,为虚拟目录设置不同的应用程序池会产生其他后果,例如缺乏共享内存会话状态的能力。在这种情况下,您必须使用进程外存储。
Different virtual directories can have different application pools. If they share the same app pool and blow up then the whole app crashes. If you have different app pools configured for the virtual directories then they are isolated.
Bear in mind that setting up different app pools for your virtual directories has other consequences such as the lack of ability to share in memory session state. In this case you have to use out-of-process storage.