在 IIS 7.x 的上下文中,Web 应用程序和虚拟文件夹之间有什么区别? [英] What's the difference between Web App and Virtual Folder in the context of IIS 7.x?

查看:20
本文介绍了在 IIS 7.x 的上下文中,Web 应用程序和虚拟文件夹之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我部署我的网站时,我发现我可以将文件夹转换为虚拟文件夹或 Web 应用程序,我完全对这两个概念感到困惑.

As I deploy my web site, I found that I could convert a folder into a virtual folder or web application, I am totally confused about these 2 concepts.

  • 为什么有两种不同的类型?

  • Why there are two different types?

每个的目的是什么?

推荐答案

虚拟文件夹或虚拟目录只是指向服务器上某处物理文件夹的链接.该文件夹成为网站结构的一部分,您可以使用 URL 路径部分中的虚拟目录.在虚拟目录中执行的代码将在与其父目录相同的应用程序"中执行.

A Virtual Folder or Virtual Directory is just a link to a physical folder somewhere on the server. This folder becomes part of the website structure and you can use the virtual directory in the path part of URLs. Code that executes in Virtual Directories will execute in the same "Application" as it's parent.

应用程序是在该文件夹"内运行的代码具有自己的会话状态和应用程序状态的地方.它实际上是一个新的独立应用程序,它位于根应用程序之下.

An Application is where the code that runs inside that "folder" has it's own Session state and Application state. It is in effect a new standalone application living underneath the root application.

例如,如果您要将 ASP.NET 应用程序部署到具有名为 /myapp 的应用程序文件夹的站点,那么该应用程序将拥有自己的应用程序域、会话状态、应用程序状态与在 / 中运行的另一个 ASP.NET 应用程序分开.例如:如果您在根应用程序中设置应用程序值 Application["Thing"] = 123 然后在 /myapp 中执行相同但具有不同值的操作,则 </myapp 中的赋值不会覆盖根中的 code>Application["Thing"].

For example, if you were to deploy an ASP.NET application into a site that had an Application folder called /myapp then that application would have it's own application domain, session state, application state completely separate from another ASP.NET application running in /. For example: if you set an Application value Application["Thing"] = 123 in the root application and then did the same but with a different value in /myapp then Application["Thing"] in the root would not be overwritten by the assignment in /myapp.

您可以对应用程序做的另一件事是指定一个不同的应用程序池来运行.例如,您的根 / 应用程序可能包含一个 ASP.NET 2.0 应用程序并在为 .NET 2.0 配置的池中运行.但是,您可能希望运行用 ASP.NET 4.0 编写的博客或论坛应用程序.现在,因为您不能在同一个应用程序池中混合使用 ASP.NET 运行时版本,您可以指定一个专门用于 ASP.NET 4.0 应用程序的替代应用程序池.

Another thing you can do with Application's is specify a different Application Pool to run under. For example your root / application might contain an ASP.NET 2.0 application and run in a pool configured for .NET 2.0. However you may want to run a blog or forum application written in ASP.NET 4.0. Now because you can't mix ASP.NET runtime versions in the same application pool, you can specify an alternative application pool specifically for ASP.NET 4.0 applications.

应用程序也可以像虚拟目录一样运行,您可以将应用程序文件夹指向服务器上其他位置的物理文件夹.

Applications can also behave like Virtual Directories and you can point an application folder at a physical folder elsewhere on the server.

如果您对 IIS7 上的虚拟目录和应用程序的底层机制感兴趣,请查看我不久前发布的这个答案:

If you're interested in the underlying mechanics of Virtual Directories and Applications on IIS7 then have a look at this answer I posted a while back:

使用 ServerManager 在应用程序内创建应用程序

这篇关于在 IIS 7.x 的上下文中,Web 应用程序和虚拟文件夹之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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