Web 应用程序的连接点还是虚拟目录?

发布于 2024-09-05 00:48:44 字数 222 浏览 13 评论 0原文

我发现连接是许多项目中引用共享代码的常见方式。不过,我以前没有见过它们在 Web 应用程序中使用过。

我们的团队正在探索放弃虚拟目录而转而使用连接的可能性,以简化我们的构建过程。我的目标是编制一份利弊清单,以便就这一变化做出明智的决定。

在Web应用程序项目上使用联结还是虚拟目录更合适?

环境是ASP.NET、IIS6/IIS7、VS.NET。

I see that junctions are a common way of referencing shared code in many projects. However, I have not seen them used in web applications before.

Our team is exploring the possibility of abandoning virtual directories in favor of junctions to simplify our build process. My goal is to compile a list of pros and cons in order to make an informed decision regarding this change.

Is it more appropriate to use junctions or virtual directories on web application projects?

Environment is ASP.NET, IIS6/IIS7, VS.NET.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小猫一只 2024-09-12 00:48:44

虚拟目录与结点就像比较苹果和梨:它们都创建目录的虚拟副本,并且苹果和梨都是水果,但比较到此为止。

首先,自 Windows Vista 以来,新事物是符号链接(本质上与联结相同,但也可以指向文件或远程 SMB 路径)。

例如,符号链接使您能够共享 Web 应用程序的每个部分(Web.config 和样式表除外)。这是虚拟目录永远无法做到的。

此外,虚拟目录参与 ASP.NET 的更改监视。例如,如果您尝试从应用程序中删除(文件或)目录,ASP.NET 将在请求完成后终止您的应用程序,从而导致会话丢失等。如果您不使用虚拟目录,而是使用符号链接,更改将不会被注意到,并且您的应用程序将继续运行。

请务必记住,符号链接并不是 Windows 中的日常功能。是的,您可以看到文件或目录在资源管理器中链接,但它并不能立即看到其链接的内容。此外,从代码中很难看出文件是否已链接,因此,如果您不小心从一百万个符号链接中删除了正在链接的文件,所有这些符号链接都会突然“停止存在”。

符号链接还可以加快同一应用程序的多个实例的部署速度,因为您唯一要做的就是复制一些实际文件,然后为其余所有文件创建指向源文件的符号链接。

Virtual directories vs. junctions is like comparing apples to pears: they both create sort of a virtual copy of a directory, as well as apples and pears are both fruits, but the comparison ends there.

First off, since Windows Vista, the new thing is symbolic links (which are essentially the same as junctions but can also point to a file or remote SMB path).

Symbolic links enable you to, for example, share every part of a web application except its Web.config and a stylesheet. This is something virtual directories can never do.

Also, virtual directories participate in ASP.NET's change monitoring. If you try and delete (a file or) directory from within your application, for instance, ASP.NET kills your app after the request completes, resulting in loss of session, etc. If instead of using a virtual directory, you use a symbolic link, the change will not be noticed and your app will keep on churning.

It's important to keep in mind that symbolic links are not an everyday feature in Windows. Yes, you can see that a file or directory is linked in Explorer, but it's not instantly visible to what it is linked. Also, from code it is much harder to see if a file is linked, so if you accidently delete the file that is being linked to from a million symbolic links, all those symbolic links suddenly 'stop existing'.

Symbolic links also speed up deployment of multiple instances of the same application, since the only thing you have to do is copy a few actual files, and then create symbolic links to the source files for all the rest.

沉睡月亮 2024-09-12 00:48:44

如果使用虚拟文件夹,您需要在每个环境上安装 IIS。然而,使用这两种方法,您都需要在每次更改后手动维护所有引用(例如,有人添加了一个引用的情况),这并不方便。

考虑将 VCS 与参考系统一起使用。例如带有 外部 的 SVN。在这种情况下,您将拥有:

  1. 自动更新每个环境的引用。
  2. 能够在不同版本的外部代码中引用。这将避免每次外部代码更改后都需要更改所有依赖应用程序的情况。

In case with virtual folders you need IIS installed on each environment. However with both approaches you need to manually maintain all references after each change (For example situation when someone added one more reference), which is not convinient.

Consider using VCS with referncing system. For example SVN with externals. In that case you will have:

  1. Automatic update of references on each environment.
  2. Ability to have references in different versions of external code. This will avoid situations when it is needed to change all dependent applications after each external code change.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文