Junctions or Virtual Directories for Web Applications?

前端 未结 2 872
再見小時候
再見小時候 2021-01-24 01:49

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

相关标签:
2条回答
  • 2021-01-24 02:20

    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.

    0 讨论(0)
  • 2021-01-24 02:34

    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.
    0 讨论(0)
提交回复
热议问题