简体   繁体   English

从外部文件夹加载asp.net dll

[英]Load asp.net dlls from external folder

I have 50 SAME asp.net websites hosted on IIS. 我在IIS上托管了50个相同的asp.net网站。 Something like WordPress, where each website though same has different content. 诸如WordPress之类的东西,尽管每个网站都具有不同的内容。

C:\inetpub\vhosts\website1.com    
C:\inetpub\vhosts\website2.com
C:\inetpub\vhosts\website3.com
.    
.    
.    
C:\inetpub\vhosts\website50.com

Since these are exactly same copies of the ASP.NET website; 由于这些是ASP.NET网站的完全相同的副本;因此, I want to use a 'common' bin folder so that I don't load 50 copies of the same set of DLLs to update and load in memory each time. 我想使用“公用” bin文件夹,这样我就不会每次都加载50组相同的DLL副本来更新和加载到内存中。

The solutions here: Is there a way to change .net mvc bin dir location? 这里的解决方案: 是否可以更改.net mvc bin目录位置? DO NOT work as I want the DLLs to be placed outside the website folder, so that they can be shared. 我不能将DLL放置在网站文件夹之外,因此不能共享它们。

One little detail you should know about IIS and ASP.NET; 您应该了解有关IIS和ASP.NET的一些细节。 they do not actually run the files in the bin folder . 他们实际上并没有运行bin文件夹中的文件 Rather, they copy the files in the bin folder into a "shadow directory" (something like "C:\\WINDOWS\\Microsoft.NET\\Framework\\v4.5.XXXX\\Temporary ASP.NET Files"). 相反,他们将bin文件夹中的文件复制到“影子目录”(类似于“ C:\\ WINDOWS \\ Microsoft.NET \\ Framework \\ v4.5.XXXX \\ Temporary ASP.NET Files”)。 It is from there that they are actually executed. 实际上是从那里开始执行它们的。 The bin folder is monitored for any changes, and the shadow directory is updated as needed. 监视bin文件夹中的所有更改,并根据需要更新影子目录。 This allows you to deploy new DLLs even when the site is running-- otherwise, they'd be locked. 这样,即使站点正在运行,您也可以部署新的DLL,否则它们将被锁定。

So... no matter what you do, the O/S is going to load multiple images of the same DLL, even if you get them to all use the same bin folder. 所以...无论您做什么,操作系统都将加载同一DLL的多个映像,即使您将它们全部使用同一bin文件夹也是如此。 As far as I know there is no way to turn this off. 据我所知,没有办法将其关闭。

That being said, if you want to save a bit of disk space and get your sites to use a common bin folder, consider using a symbolic link . 话虽如此,如果您想节省一些磁盘空间并让您的站点使用公共bin文件夹,请考虑使用符号链接 This essentially allows you to create a directory that "points" at another directory (this sort of thing is more common in Unix). 本质上,这使您可以创建一个“指向”另一个目录的目录(这种情况在Unix中更为常见)。 Thus you end up with one copy being accessed from several places. 因此,最终您会从多个地方访问一个副本。 Just one word of caution: be very careful when deleting things, because you could delete folders from all 50 of your sites without meaning to. 请注意:删除内容时要非常小心,因为您可能会毫无意义地从所有50个站点中删除文件夹。

But a better option (depending on why you are running 50 identical sites, which is very unusual) is to run just ONE site, with one IP address, but with several DNS entries pointed at that IP. 但是更好的选择(取决于为什么要运行50个相同的站点,这是非常不寻常的)是仅运行一个站点,具有一个IP地址,但有多个指向该IP的DNS条目。 This way it would look like you have 50 sites when you only have one. 这样,当您只有一个站点时,您将拥有50个站点。 The trick here is (if you are using https) you'll have to use host headers to pick the SSL cert so that browsers don't show a phishing warning. 这里的技巧是(如果使用的是https),则必须使用主机标头来选择SSL证书,这样浏览器才不会显示网络钓鱼警告。 Or, if your site is load balanced, you could terminate SSL at the load balancer (a strategy known as SSL offloading ) so that a cert at the IIS level isn't even needed. 或者,如果您的站点是负载平衡的,则可以在负载平衡器处终止SSL(一种称为SSL offloading的策略),从而甚至不需要IIS级别的证书。

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

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