如何仅使用 2 个虚拟目录托管多个 Web 应用程序

发布于 2024-07-08 02:47:00 字数 141 浏览 4 评论 0原文

我的共享主机只允许我创建 2 个虚拟目录。 我想托管多个 Web 应用程序...比如 ASP.NET MVC 博客、论坛、个人网站等...

没有其他方法可以做到这一点吗? 我不能简单地将博客文件夹 ftp 到我的虚拟目录之一,然后在线访问它吗?

my shared hosting only allows me to create 2 virtual directories. and i want to host multiple webapps... say an asp.net mvc blog, a forum, a personal site etc...

isnt there any other way of doing this? cant i simply just ftp the blog folder to one of my virtual directories and then access it online??

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

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

发布评论

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

评论(2

忆离笙 2024-07-15 02:47:00

对于 ASP.NET Web 应用程序,通常每个应用程序都位于自己的虚拟目录中,该目录作为应用程序的起点。

从技术上讲,您可以通过以下两种方式之一“搭载”同一应用程序起点上的两个应用程序:

  1. 将每个应用程序的所有文件放在同一目录(和适当的子目录)中

如果您没有任何重叠的文件,你可以摆脱这个。 当然,您可能不会使用默认页面或索引页面等文件。无论如何,这会很混乱。

  1. 将每个应用程序的所有非二进制文件放在适当的子目录中,并将二进制文件放在主虚拟的 \bin 目录中。

仅当每个应用程序的二进制文件的名称不重叠并且程序集之间不存在命名空间歧义冲突(两个文件名不同的程序集,但具有相同的命名空间)时,您才能执行此操作。 如果您尝试搭载两个不同的应用程序,则后者发生的可能性要小得多。

我发现后一个解决方案的一个大问题是应用程序中使用应用程序根引用的任何部分都会损坏。 当某些代码尝试基于应用程序根引用(例如〜)解析对某些资源(例如图像)的引用时,

~/images/logo.gif

将解析为虚拟目录,但不会包含附加(非虚拟和非应用程序起点) ) 应用程序所在的子目录。 所以,

/vd1/app1/images/logo.gif

你最终会得到这样的结果:

/vd1/images/logo.gif

显然,这是行不通的。

所以...如果您可以将它们放在同一个虚拟目录中,您就不会破坏任何一个应用程序,但是,您必须检查文件冲突等。 如果没有单独的应用程序起点,可能的命名空间冲突将是不可避免的。

For ASP.NET web applications, typically each would live in its own virtual directory which serves as the application starting point.

Technically you could "piggy-back" two applications on the same application starting point in one of two ways:

  1. Put all the files for each application in the same directory (and appropriate sub directories)

If you don't have ANY files that overlap, you can get away with this. Of course, it's likely that you won't with such files as the default or index pages, etc. And this would be pretty messy anyway.

  1. Put all the non-binary files for each app in an appropriate subdirectory and the binaries in the main virtual's \bin directory.

You'll be able to do this only if each application's binary files don't overlap by name AND there are no namespace ambiguity conflicts between assemblies (two different assemblies by file name, but with the same namespace). The latter is much less likely to happen if you are trying to piggy-back two different applications.

The big problem I see with the latter solution is that any parts of the application that make use of application root references will break. When some code tries to resolve a reference to some resource (like an image) based on an application root reference such as

~/images/logo.gif

the ~ will get resolved to the virtual directory, but will not include the additional (non-virtual and non-app starting point) subdirectory in which the application lives. So instead of this:

/vd1/app1/images/logo.gif

you'll end up with this:

/vd1/images/logo.gif

Obviously, that won't work.

So... you won't break either app if you can put them both in the same virtual directory, however, you'll have to check for file conflicts and such. Possible namespace conflicts will be unavoidable without separate application starting points.

情深已缘浅 2024-07-15 02:47:00

您不能将每个应用程序放在任一虚拟目录中的单独子目录中吗? 例如,如果您有 http://server.com/vd1,您可以像 http://server.com/vd1/app1http://server.com/vd1/app2

Can't you just put each app in a separate subdirectory in either of the virtual directories. e.g. if you had http://server.com/vd1, you could partition it like http://server.com/vd1/app1, http://server.com/vd1/app2, etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文